26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
51 #pragma package(smart_init)
64 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
66 for(
int x = 0; x < 4; x++)
77 else if(SpeedTagVal == 77)
81 else if(SpeedTagVal == 78)
85 else if(SpeedTagVal == 79)
89 else if(SpeedTagVal == 96)
93 else if(SpeedTagVal == 129)
97 else if(SpeedTagVal == 130)
101 else if(SpeedTagVal == 131)
105 else if(SpeedTagVal == 145)
109 else if(SpeedTagVal == 146)
118 FixedNamedLocationElement(false)
120 for(
int x = 0; x < 4; x++)
131 AnsiString(VLocInput));
144 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
158 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
174 Graphics::TBitmap *GraphicOutput = GraphicPtr;
176 if(LocationName ==
"")
221 GraphicOutput = GraphicPtr;
225 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
227 if((TrackType ==
Simple) && Failed)
239 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
240 AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit01) +
"," + AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit23) +
",EndTrkEl,";
249 Attribute(0), CallingOnSet(false), Length01(
Utilities->DefaultTrackLength), Length23(-1), SpeedLimit01(
Utilities->DefaultTrackSpeedLimit), SpeedLimit23(-1),
250 TrainIDOnElement(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit01(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit23(-1), StationEntryStopLinkPos1(-1),
251 StationEntryStopLinkPos2(-1), StationEntryStopLinkPos3(-1), StationEntryStopLinkPos4(-1), SigAspect(FourAspect)
254 for(
int x = 0; x < 4; x++)
270 if(lower.second < higher.second)
274 else if(lower.second > higher.second)
278 else if(lower.second == higher.second)
280 if(lower.first < higher.first)
293 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
294 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
298 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
309 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
337 {2, 4}, {6, 2}, {8, 6}, {4, 8},
338 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
348 else if(
Link[2] == -1)
361 else if(
Link[2] == -1)
370 for(
int x = 0; x < 16; x++)
372 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
548 throw Exception(
"Error in EntryExitNumber 4");
643 throw Exception(
"Error in EntryExitNumber 5");
737 throw Exception(
"Error in EntryExitNumber 6");
824 throw Exception(
"Error in EntryExitNumber 10");
913 throw Exception(
"Error in EntryExitNumber 11");
1009 throw Exception(
"Error in EntryExitNumber 7");
1040 throw Exception(
"Error in EntryExitNumber 8");
1051 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1053 if(!AutoSigsFlag && !PrefDirRoute)
1057 else if(!AutoSigsFlag && PrefDirRoute)
1068 throw Exception(
"Error in EntryExitNumber 9");
1165 AnsiString NL =
'\n';
1167 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable, perhaps because of failed points; " + NL + NL +
1168 "reachable but too far ahead or with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1169 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1170 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1177 int InternalLinkCheckArray[9][2] =
1178 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1183 for(
int x = 0; x < 9; x++)
1185 for(
int y = 0; y < 2; y++)
1192 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1194 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1195 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1196 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1197 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 18 << 19 << 20 << 21 << 22 << 23 << 24
1198 << 25 << 26 << 27 << 28 << 29 << 30 << 31 << 32 << 33 << 34 << 35 << 36 << 37 << 38 << 39 << 40 << 41 << 42 << 43 << 44 << 45 << 46 << 47
1199 << 60 << 61 << 62 << 63 << 64 << 65 << 66 << 67 << 68 << 69 << 70 << 71 << 72 << 73 << 74 << 75 << 80 << 81 << 82 << 83 << 84 << 85 << 86
1200 << 87 << 125 << 126 << 127 << 128 << 132 << 133 << 134 << 135 << 136 << 137 << 138 << 139
1201 << 140 << 141 << 142 << 143;
1206 int HVArray[10][2] =
1207 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1209 for(
int x = 0; x < 10; x++)
1211 for(
int y = 0; y < 2; y++)
1220 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1223 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1224 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1226 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1227 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1229 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1230 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1233 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1236 for(
int x = 0; x < 40; x++)
1242 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1245 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1246 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1248 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1249 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1251 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1252 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1255 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1258 for(
int x = 0; x < 40; x++)
1264 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1267 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1268 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1270 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1271 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1273 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1274 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1277 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1280 for(
int x = 0; x < 40; x++)
1306 for(
int x = 0; x < 40; x++)
1312 {{68, 0,
RailGraphics->
FSig68}, {69, 0,
RailGraphics->
FSig69}, {70, 0,
RailGraphics->
FSig70}, {71, 0,
RailGraphics->
FSig71}, {72, 0,
RailGraphics->
FSig72},
1315 for(
int x = 0; x < 8; x++)
1321 {{68, 0,
RailGraphics->
FGSig68}, {69, 0,
RailGraphics->
FGSig69}, {70, 0,
RailGraphics->
FGSig70}, {71, 0,
RailGraphics->
FGSig71}, {72, 0,
RailGraphics->
FGSig72},
1324 for(
int x = 0; x < 8; x++)
1351 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1352 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1353 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1354 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1355 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1356 {0, 0, 129}, {0, -1, 145},
1359 for(
int x = 0; x < 25; x++)
1361 for(
int y = 0; y < 3; y++)
1369 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1370 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1371 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1372 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1373 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1374 {0, 0, 129}, {0, 1, 145},
1377 for(
int x = 0; x < 25; x++)
1379 for(
int y = 0; y < 3; y++)
1387 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1388 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1389 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1390 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1391 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1392 {0, 0, 130}, {-1, 0, 146},
1395 for(
int x = 0; x < 25; x++)
1397 for(
int y = 0; y < 3; y++)
1405 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1406 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1407 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1408 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1409 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1410 {0, 0, 130}, {1, 0, 146},
1413 for(
int x = 0; x < 25; x++)
1415 for(
int y = 0; y < 3; y++)
1423 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1424 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1425 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1426 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1427 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1428 {0, -1, 129}, {1, 0, 130},
1429 {-1, 0, 130}, {0, 1, 145},
1430 {0, -1, 145}, {1, 0, 146},
1433 for(
int x = 0; x < 28; x++)
1435 for(
int y = 0; y < 3; y++)
1453 for(
int x = 0; x < 8; x++)
1455 for(
int y = 0; y < 3; y++)
1473 for(
int x = 0; x < 8; x++)
1475 for(
int y = 0; y < 3; y++)
1493 for(
int x = 0; x < 8; x++)
1495 for(
int y = 0; y < 3; y++)
1513 for(
int x = 0; x < 8; x++)
1515 for(
int y = 0; y < 3; y++)
1523 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1525 for(
int x = 0; x < 4; x++)
1527 for(
int y = 0; y < 3; y++)
1535 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1536 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1537 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1538 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1544 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1545 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1546 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1547 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1553 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1554 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1555 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1556 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1562 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1563 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1564 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1565 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1587 delete UGMIt->second;
1663 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1664 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1666 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1673 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1674 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1687 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1688 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1690 {4, 6, 2, 8}, {1, 9, 3, 7},
1692 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1694 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1697 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1698 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1699 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1700 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1701 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1702 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1703 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1705 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1706 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1707 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1708 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1709 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1710 {4, 6, -1, -1}, {2, 8, -1, -1},
1712 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1714 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1716 {4, 6, -1, -1}, {2, 8, -1, -1},
1721 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1722 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1723 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1724 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1727 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1728 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1729 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1731 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1732 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1733 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1735 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1737 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1738 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1739 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1740 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1741 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1742 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1743 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1744 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1745 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1746 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1747 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1748 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1749 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1751 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1752 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1753 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1754 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1755 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1756 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1757 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1758 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1762 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1763 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1764 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1770 for(
int x = 0; x < 17; x++)
1772 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1774 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1778 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1784 ExistingGraphicLoaded(false), Width(16), Height(16)
1796 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1834 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1838 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1842 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1846 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1869 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1872 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1876 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1880 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1914 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1935 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1949 bool TrackPresent =
false;
1963 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1967 TrackPresent =
true;
1972 return(!TrackPresent);
1980 bool TrackPresent =
false;
1989 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1993 TrackPresent =
true;
1999 return(!TrackPresent);
2004 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
2007 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2008 TrackEraseSuccessfulFlag =
false;
2013 ErasedTrackVectorPosition = -1;
2014 AnsiString SName =
"", ErrorString;
2016 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
2022 TrackMapKeyPair.first = HLocInput;
2023 TrackMapKeyPair.second = VLocInput;
2024 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
2035 if(ErrorString !=
"")
2037 throw Exception(ErrorString +
" for EraseTrackElement 1");
2061 ErasedTrackVectorPosition = VecPos;
2062 TrackEraseSuccessfulFlag =
true;
2068 unsigned int VecPos;
2069 InactiveTrackMapKeyPair.first = HLocInput;
2070 InactiveTrackMapKeyPair.second = VLocInput;
2075 VecPos = InactiveTrack2MultiMapIterator->second;
2080 if(ErrorString !=
"")
2082 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2092 TrackEraseSuccessfulFlag =
true;
2113 VecPos = InactiveTrack2MultiMapIterator->second;
2118 if(ErrorString !=
"")
2120 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2144 if(TrackEraseSuccessfulFlag)
2160 void TTrack::PlotAndAddTrackElement(
int Caller,
int CurrentTag,
int Aspect,
int HLocInput,
int VLocInput,
bool &TrackLinkingRequiredFlag,
bool InternalChecks,
bool PerformNameSearch)
2167 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2168 bool PlatAllowedFlag =
false;
2170 TrackLinkingRequiredFlag =
false;
2182 LocationNameEntry.first =
"";
2190 TempTrackElement.
HLoc = HLocInput;
2191 TempTrackElement.
VLoc = VLocInput;
2217 else if(Aspect == 1)
2221 else if(Aspect == 2)
2225 else if(Aspect == 3)
2234 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2237 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2239 if(InactiveFoundFlag)
2243 NonStationOrLevelCrossingPresent =
true;
2247 NonStationOrLevelCrossingPresent =
true;
2251 PlatformPresent =
true;
2262 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2270 PlatAllowedFlag =
true;
2274 PlatAllowedFlag =
true;
2278 PlatAllowedFlag =
true;
2282 PlatAllowedFlag =
true;
2286 TrackLinkingRequiredFlag =
true;
2288 if(PerformNameSearch)
2317 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2318 (!FoundFlag && !InactiveFoundFlag))
2321 TrackLinkingRequiredFlag =
true;
2323 if(PerformNameSearch)
2356 TrackLinkingRequiredFlag =
true;
2368 else if(FoundFlag || InactiveFoundFlag)
2381 if(PerformNameSearch)
2390 bool BothPointFillets =
true;
2405 TrackLinkingRequiredFlag =
true;
2407 if(InternalChecks && PerformNameSearch)
2419 bool InternalChecks)
2423 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2424 bool PlatAllowedFlag =
false;
2426 TrackLinkingRequiredFlag =
false;
2429 LocationNameEntry.first =
"";
2435 TempTrackElement.
HLoc = HLocInput;
2436 TempTrackElement.
VLoc = VLocInput;
2437 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2438 for(
int x = 0; x < 4; x++)
2444 TempTrackElement.
Conn[x] = -1;
2458 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2460 if(InactiveFoundFlag)
2464 NonStationOrLevelCrossingPresent =
true;
2468 NonStationOrLevelCrossingPresent =
true;
2472 PlatformPresent =
true;
2483 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2491 PlatAllowedFlag =
true;
2495 PlatAllowedFlag =
true;
2499 PlatAllowedFlag =
true;
2503 PlatAllowedFlag =
true;
2507 TrackLinkingRequiredFlag =
true;
2538 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2539 (!FoundFlag && !InactiveFoundFlag))
2542 TrackLinkingRequiredFlag =
true;
2579 TrackLinkingRequiredFlag =
true;
2591 else if(FoundFlag || InactiveFoundFlag)
2610 bool BothPointFillets =
true;
2625 TrackLinkingRequiredFlag =
true;
2655 ShowMessage(
"Gaps must be set before track can be validated");
2665 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2676 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2693 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2700 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2724 std::pair<AnsiString, char>TempMapPair;
2732 TempMapPair.second =
'x';
2742 AnsiString Name =
"";
2743 typedef std::list<AnsiString> TNoPlatsList;
2744 TNoPlatsList::iterator NPLIt;
2745 TNoPlatsList NoPlatsList;
2746 typedef std::list<AnsiString> TLocNameList;
2747 TLocNameList LocNameList;
2752 LocNameList.push_back(LNMMIt->first);
2755 LocNameList.unique();
2756 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2760 if(MMRange.first == MMRange.second)
2766 if((LNMMIt->second) < 0)
2780 TempIt = MMRange.second;
2781 if(LNMMIt == --TempIt)
2783 NoPlatsList.push_back(Name);
2787 if(!NoPlatsList.empty())
2789 AnsiString NoPlatsAnsiList =
"";
2790 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2792 NoPlatsAnsiList += *NPLIt +
'\n';
2796 if(NoPlatsList.size() > 1)
2798 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2802 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2817 int NewHLoc, NewVLoc;
2818 bool ConnectionFoundFlag, LinkFoundFlag;
2820 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2822 for(
unsigned int y = 0; y < 4; y++)
2840 ConnectionFoundFlag =
false;
2841 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2847 ConnectionFoundFlag =
true;
2849 LinkFoundFlag =
false;
2850 for(
unsigned int a = 0; a < 4; a++)
2854 LinkFoundFlag =
true;
2870 if(!ConnectionFoundFlag)
2945 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2962 bool UnsetGaps =
false;
2969 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2973 for(
unsigned int y = 0; y < 4; y++)
2985 for(
unsigned int y = 0; y < 4; y++)
2995 for(
unsigned int y = 1; y < 4; y++)
3004 for(
unsigned int y = 0; y < 4; y++)
3017 for(
unsigned int y = 0; y < 4; y++)
3045 int NumberOfActiveElements = 0;
3047 GraphicsFollow =
false;
3051 if(MarkerString[MarkerString.Length()] ==
'1')
3053 GraphicsFollow =
true;
3055 for(
int x = 0; x < NumberOfActiveElements; x++)
3061 TrackElement.
HLoc = TempInt;
3063 TrackElement.
VLoc = TempInt;
3069 TrackElement.
Conn[0] = TempInt;
3093 if((TempInt != -1) && (TempInt < 10))
3103 if((TempInt != -1) && (TempInt < 10))
3120 if(Marker[1] ==
'3')
3124 else if(Marker[1] ==
'2')
3128 else if(Marker[1] ==
'G')
3142 int NumberOfInactiveElements = 0;
3146 for(
int x = 0; x < NumberOfInactiveElements; x++)
3152 TrackElement.
HLoc = TempInt;
3154 TrackElement.
VLoc = TempInt;
3160 bool LocError =
false;
3189 for(
int x = 0; x < NumberOfGraphics; x++)
3200 bool FileError =
false;
3202 for(
int x = 0; x < NumberOfGraphics; x++)
3215 UGME.second =
new TPicture;
3216 UGME.second->LoadFromFile(
UGME.first);
3219 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3226 catch(
const EInvalidGraphic &e)
3235 delete UGMIt->second;
3240 catch(
const Exception &e)
3249 delete UGMIt->second;
3257 bool FoundInMap =
false;
3276 UGME.second =
new TPicture;
3277 UGME.second->LoadFromFile(
UGME.first);
3280 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3287 catch(
const EInvalidGraphic &e)
3296 delete UGMIt->second;
3301 catch(
const Exception &e)
3310 delete UGMIt->second;
3335 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3339 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3341 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3344 VecFile << x <<
'\n';
3345 VecFile << TrackElement.
SpeedTag <<
'\n';
3346 VecFile << TrackElement.
HLoc <<
'\n';
3347 VecFile << TrackElement.
VLoc <<
'\n';
3351 VecFile << TrackElement.
Conn[0] <<
'\n';
3355 VecFile << TrackElement.
Attribute <<
'\n';
3361 VecFile << int(1) <<
'\n';
3365 VecFile << int(0) <<
'\n';
3368 VecFile << TrackElement.
Length01 <<
'\n';
3369 VecFile << TrackElement.
Length23 <<
'\n';
3372 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3379 VecFile <<
"3*****" <<
'\0' <<
'\n';
3383 VecFile <<
"2*****" <<
'\0' <<
'\n';
3387 VecFile <<
"G*****" <<
'\0' <<
'\n';
3391 VecFile <<
"4*****" <<
'\0' <<
'\n';
3396 VecFile <<
"******" <<
'\0' <<
'\n';
3401 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3405 VecFile << x <<
'\n';
3406 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3407 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3408 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3409 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3410 VecFile <<
"******" <<
'\0' <<
'\n';
3425 GraphicsFollow =
false;
3427 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3433 AnsiString MarkerString;
3440 if(MarkerString[MarkerString.Length()] ==
'1')
3442 GraphicsFollow =
true;
3444 for(
int x = 0; x < NumberOfActiveElements; x++)
3452 int SpeedTag = TempInt;
3459 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3465 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3470 if((SpeedTag > 87) && (SpeedTag < 96))
3473 if((TempInt < -1) || (TempInt > 3))
3479 if((TempInt < -1) || (TempInt > 999999))
3485 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3486 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3489 if((TempInt < -1) || (TempInt > 5))
3495 if((SpeedTag >= 68) && (SpeedTag <= 75))
3498 if((TempInt != 0) && (TempInt != 1))
3505 if((TempInt < -1) || (TempInt > 999999))
3511 if((TempInt < -1) || (TempInt > 999999))
3517 if((TempInt < -1) || (TempInt > 999999))
3523 if((TempInt < -1) || (TempInt > 999999))
3544 int NumberOfInactiveElements = 0;
3547 if(NumberOfInactiveElements < 0)
3557 for(
int x = 0; x < NumberOfInactiveElements; x++)
3571 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3577 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3604 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3610 AnsiString FileName =
"", TempStr =
"";
3612 for(
int x = 0; x < NumberOfGraphics; x++)
3614 TPicture *TempPicture =
new TPicture;
3623 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3636 catch(
const EInvalidGraphic &e)
3641 for(
int y = x + 1; y < NumberOfGraphics; y++)
3647 ShowMessage(FileName +
3648 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3653 catch(
const Exception &e)
3658 for(
int y = x + 1; y < NumberOfGraphics; y++)
3664 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3665 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3683 for(
int x = 0; x < VecSize; x++)
3706 for(
int x = 0; x < VecSize; x++)
3728 for(
int x = 0; x < VecSize; x++)
3782 for(
int x = 0; x < VecSize; x++)
3840 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3862 if(BothPointFilletsAndBasicLCs)
3939 Bitmap->Canvas->CopyMode = cmSrcCopy;
3941 Graphics::TBitmap *GraphicOutput;
4116 for(
int x = 0; x < 40; x++)
4145 Graphics::TBitmap *GraphicPtr;
4160 Graphics::TBitmap* SignalPlatformGraphic;
4193 if(OldTransparentColour !=
clB5G5R5)
4216 Bitmap->Canvas->CopyMode = cmSrcCopy;
4244 Bitmap->Canvas->CopyMode = cmSrcCopy;
4246 Graphics::TBitmap *GraphicOutput;
4256 if(BaseElement == 1)
4352 for(
int x = 0; x < 40; x++)
4381 Graphics::TBitmap *GraphicPtr;
4396 Graphics::TBitmap* SignalPlatformGraphic;
4459 for(
int x = 0; x < 40; x++)
4467 Graphics::TBitmap* SignalPlatformGraphic;
4508 if(OldTransparentColour !=
clB5G5R5)
4522 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4594 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4608 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4634 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4659 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4689 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4723 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4760 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4778 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4799 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4831 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4838 throw Exception(
"Error - Map & Vector different sizes");
4840 unsigned int NonZeroCount = 0;
4842 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4851 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4857 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4861 TrackMapEntry.first = TrackMapKeyPair;
4862 TrackMapEntry.second = x;
4863 if(!(
TrackMap.insert(TrackMapEntry).second))
4865 throw Exception(
"Error - map insertion failure, TrackVector in error");
4869 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4871 for(
unsigned int y = 0; y < 4; y++)
4896 THVPair GapMapKeyPair, GapMapValuePair;
4899 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4905 GapMapEntry.first = GapMapKeyPair;
4908 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4912 GapMapEntry.second = GapMapValuePair;
4915 GapMap.insert(GapMapEntry);
4930 bool TrackElementPositionsOK =
true;
4932 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4944 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4945 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4946 "can't connect to an underpass or vice versa)");
4954 for(
unsigned int y = 0; y < 4; y++)
4972 bool ConnectionFoundFlag;
4976 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4982 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4991 if(ConnectionFoundFlag)
4996 bool ExitSignal =
false;
5007 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
5009 TrackElementPositionsOK =
false;
5014 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
5016 TrackElementPositionsOK =
false;
5021 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
5025 TrackElementPositionsOK =
false;
5030 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
5033 TrackElementPositionsOK =
false;
5045 ShowMessage(
"Bridge next to a signal - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
5048 TrackElementPositionsOK =
false;
5053 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
5054 TrackElementPositionsOK =
false;
5057 if(!TrackElementPositionsOK)
5064 throw Exception(
"Error in track element positions in FinalCall");
5077 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5083 for(
unsigned int y = 0; y < 4; y++)
5105 bool ConnectionFoundFlag;
5106 bool LinkMatchFound =
false;
5109 if(ConnectionFoundFlag)
5111 for(
unsigned int a = 0; a < 4; a++)
5117 LinkMatchFound =
true;
5128 throw Exception(
"Error in final track linkage - - no matching link found");
5141 throw Exception(
"Error in final track linkage - connection not found");
5157 bool ConnErrorFlag =
false;
5159 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5163 ConnErrorFlag =
true;
5167 ConnErrorFlag =
true;
5171 ConnErrorFlag =
true;
5175 ConnErrorFlag =
true;
5184 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5193 throw Exception(
"ConnError in LinkTrack - Final");
5197 throw Exception(
"ConnError in LinkTrack - Precheck");
5200 bool CLkErrorFlag =
false;
5202 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5206 CLkErrorFlag =
true;
5210 CLkErrorFlag =
true;
5214 CLkErrorFlag =
true;
5218 CLkErrorFlag =
true;
5226 throw Exception(
"CLkError in LinkTrack - Final");
5230 throw Exception(
"CLkError in LinkTrack - Precheck");
5235 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5265 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5281 for(
unsigned int y = 0; y < 4; y++)
5300 bool ConnectionFoundFlag;
5306 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5315 if(ConnectionFoundFlag)
5318 bool LinkFoundFlag =
false;
5375 for(
unsigned int a = 0; a < 4; a++)
5384 LinkFoundFlag =
true;
5392 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5402 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5416 bool ConnErrorFlag =
false;
5418 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5422 ConnErrorFlag =
true;
5426 ConnErrorFlag =
true;
5430 ConnErrorFlag =
true;
5434 ConnErrorFlag =
true;
5443 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5452 throw Exception(
"ConnError in LinkTrack - Final");
5456 throw Exception(
"ConnError in LinkTrack - Precheck");
5459 bool CLkErrorFlag =
false;
5461 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5465 CLkErrorFlag =
true;
5469 CLkErrorFlag =
true;
5473 CLkErrorFlag =
true;
5477 CLkErrorFlag =
true;
5485 throw Exception(
"CLkError in LinkTrack - Final");
5489 throw Exception(
"CLkError in LinkTrack - Precheck");
5493 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5522 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5538 for(
unsigned int y = 0; y < 4; y++)
5557 bool ConnectionFoundFlag =
false;
5559 if(ConnectionFoundFlag)
5563 bool LinkFoundFlag =
false;
5583 for(
unsigned int a = 0; a < 4; a++)
5592 LinkFoundFlag =
true;
5612 bool ConnErrorFlag =
false;
5614 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5618 ConnErrorFlag =
true;
5622 ConnErrorFlag =
true;
5626 ConnErrorFlag =
true;
5630 ConnErrorFlag =
true;
5638 bool CLkErrorFlag =
false;
5640 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5644 CLkErrorFlag =
true;
5648 CLkErrorFlag =
true;
5652 CLkErrorFlag =
true;
5656 CLkErrorFlag =
true;
5674 int Position1, Position2;
5680 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5682 int HLoc1 = GapMapPtr->first.first;
5683 int VLoc1 = GapMapPtr->first.second;
5684 int HLoc2 = GapMapPtr->second.first;
5685 int VLoc2 = GapMapPtr->second.second;
5688 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5692 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5696 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5700 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5718 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5719 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5729 bool FoundFlag =
false;
5741 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5742 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5743 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5772 bool FoundFlag =
false;
5785 TrackMapKeyPair.first = TrackElement.
HLoc;
5786 TrackMapKeyPair.second = TrackElement.
VLoc;
5787 TrackMapEntry.first = TrackMapKeyPair;
5792 LocationNameEntry.second = -(int)(
TrackVector.size());
5832 TrackMapKeyPair.first = HLoc;
5833 TrackMapKeyPair.second = VLoc;
5834 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5844 return(TrackMapPtr->second);
5857 TrackMapKeyPair.first = HLoc;
5858 TrackMapKeyPair.second = VLoc;
5859 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5862 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5863 throw Exception(Message);
5881 MapKeyPair.first = HLoc;
5882 MapKeyPair.second = VLoc;
5883 MapPtr = Map.find(MapKeyPair);
5884 if(MapPtr == Map.end())
5886 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5887 throw Exception(Message);
5892 return(Vector.at(MapPtr->second));
5902 THVPair InactiveTrackMapKeyPair;
5905 InactiveTrackMapKeyPair.first = HLoc;
5906 InactiveTrackMapKeyPair.second = VLoc;
5910 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5911 throw Exception(Message);
5925 bool Present =
true;
5929 TrackMapKeyPair.first = HLoc;
5930 TrackMapKeyPair.second = VLoc;
5931 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5946 bool Present =
true;
5947 THVPair InactiveTrackMapKeyPair;
5950 InactiveTrackMapKeyPair.first = HLoc;
5951 InactiveTrackMapKeyPair.second = VLoc;
5969 THVPair InactiveTrackMapKeyPair;
5974 InactiveTrackMapKeyPair.first = HLoc;
5975 InactiveTrackMapKeyPair.second = VLoc;
5984 if(InactiveTrackRange.first == InactiveTrackRange.second)
5993 RetPair.first = InactiveTrackRange.first->second;
5994 RetPair.second = (--InactiveTrackRange.second)->second;
6007 AnsiString(DivergingPosition));
6018 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
6019 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
6020 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
6021 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
6022 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
6023 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
6024 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
6025 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
6026 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
6027 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
6028 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
6029 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
6063 throw Exception(
"Error, Wrong track type in PlotGap");
6065 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
6069 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
6073 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
6077 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
6081 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
6085 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
6089 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
6093 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
6097 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
6101 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
6105 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
6109 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
6113 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
6117 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
6121 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
6125 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
6141 PosPair.first = TrackElement.
HLoc;
6142 PosPair.second = TrackElement.
VLoc;
6146 Disp->
PlotOutput(283, TrackElement.
HLoc * 16, TrackElement.
VLoc * 16, MOMIt->second);
6159 throw Exception(
"Error, Wrong track type in PlotPoints");
6163 bool FoundFlag =
false;
6165 if(IMPair.first > 0)
6181 else if(TrackElement.
SpeedTag < 132)
6192 else if(!TrackElement.
Failed)
6199 else if(TrackElement.
SpeedTag < 132)
6217 else if(TrackElement.
SpeedTag < 132)
6231 bool BlueLoc =
false;
6240 if(FoundFlag && !BlueLoc)
6255 bool FoundFlag =
false;
6258 throw Exception(
"Error, Wrong track type in PlotSignal");
6262 for(
int x = 0; x < 40; x++)
6278 if(IMPair.first > 0)
6345 for(
int x = 0; x < 40; x++)
6352 Graphics::TBitmap* SignalPlatformGraphic;
6354 if(IMPair.first > 0)
6376 for(
int x = 0; x < 8; x++)
6383 if(IMPair.first > 0)
6400 for(
int x = 0; x < 8; x++)
6407 if(IMPair.first > 0)
6500 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6508 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6516 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6524 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6540 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6548 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6556 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6564 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6597 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6609 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6621 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6633 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6675 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6677 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6679 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6682 if(BaseElementSpeedTag == 1)
6686 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6693 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6701 Graphics::TBitmap *RouteGraphic;
6703 if(TypeOfRoute == 1)
6707 else if(TypeOfRoute == 0)
6713 RouteGraphic = BaseGraphic;
6720 if(UpStep == DownStep)
6723 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6733 else if((DownStep - UpStep) == 1)
6738 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6748 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6761 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6771 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6787 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6797 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6807 else if(DownStep == 0)
6810 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6820 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6833 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6843 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6853 for(
int x = (UpStep + 1); x < DownStep; x++)
6858 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6862 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6883 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6890 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6896 Graphics::TBitmap *RouteGraphic;
6898 if(TypeOfRoute == 1)
6902 else if(TypeOfRoute == 0)
6908 RouteGraphic = BaseGraphic;
6917 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6927 else if((RStep - LStep) == 1)
6932 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6942 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6955 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6965 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6981 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6991 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7004 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7014 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
7027 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7037 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7047 for(
int x = (LStep + 1); x < RStep; x++)
7052 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
7056 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
7080 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7083 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7085 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7087 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7090 if(BaseElementSpeedTag == 1)
7094 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
7101 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
7107 if(UpStep == DownStep)
7118 else if((DownStep - UpStep) == 1)
7137 for(
int x = (UpStep + 1); x < DownStep; x++)
7146 for(
int x = (UpStep + 1); x < DownStep; x++)
7153 for(
int x = UpStep; x <= DownStep; x++)
7166 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
7173 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
7190 else if((RStep - LStep) == 1)
7209 for(
int x = (LStep + 1); x < RStep; x++)
7218 for(
int x = (LStep + 1); x < RStep; x++)
7225 for(
int x = LStep; x <= RStep; x++)
7244 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
7246 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7248 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
7251 if(BaseElementSpeedTag == 1)
7255 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
7262 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
7268 for(
int x = UpStep; x < (DownStep + 1); x++)
7283 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
7290 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
7296 for(
int x = LStep; x < (RStep + 1); x++)
7315 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7318 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7320 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7322 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7327 if(BaseElementSpeedTag == 1)
7331 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
7338 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
7344 for(
int x = UpStep; x <= DownStep; x++)
7358 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7365 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7371 for(
int x = LStep; x <= RStep; x++)
7387 Graphics::TBitmap *RouteGraphic;
7390 if(BaseElementSpeedTag == 1)
7392 if(TypeOfRoute == 1)
7396 else if(TypeOfRoute == 0)
7402 RouteGraphic = BaseGraphic;
7406 RouteGraphic = BaseGraphic;
7412 if(TypeOfRoute == 1)
7416 else if(TypeOfRoute == 0)
7422 RouteGraphic = BaseGraphic;
7426 RouteGraphic = BaseGraphic;
7431 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7436 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7440 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7447 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7450 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7455 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7460 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7464 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7471 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7474 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7599 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7603 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7634 "," + AnsiString(VLoc));
7638 int DummyRouteNumber;
7640 TrainPresent =
false;
7644 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7646 TrackMapKeyPair.first = HLoc;
7647 TrackMapKeyPair.second = VLoc + UpStep;
7648 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7657 TrainPresent =
true;
7671 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7673 TrackMapKeyPair.first = HLoc;
7674 TrackMapKeyPair.second = VLoc + DownStep;
7675 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7684 TrainPresent =
true;
7698 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7700 TrackMapKeyPair.first = HLoc + LeftStep;
7701 TrackMapKeyPair.second = VLoc;
7702 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7711 TrainPresent =
true;
7725 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7727 TrackMapKeyPair.first = HLoc + RightStep;
7728 TrackMapKeyPair.second = VLoc;
7729 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7738 TrainPresent =
true;
7758 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7775 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7778 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7784 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7791 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7797 for(
int x = UpStep; x <= DownStep; x++)
7804 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7811 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7817 for(
int x = LStep; x <= RStep; x++)
7833 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7840 else if(TrackElement.
SpeedTag < 132)
7858 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7875 AnsiString(ScreenPosV));
7890 AnsiString(ScreenPosV));
7901 AnsiString(VPosTrue));
7915 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7927 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7928 " in TrackMap, Caller=" + (AnsiString)Caller);
7930 if(MapVecPos != (
int)a)
7932 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7933 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7934 (AnsiString)Caller);
7940 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7941 " Caller=" + (AnsiString)Caller);
7961 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7962 " in InactiveMap, Caller=" + (AnsiString)Caller);
7964 if((InactivePair.first != a) && (InactivePair.second != a))
7966 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7967 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7968 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7973 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7974 " Caller=" + (AnsiString)Caller);
7984 int Position1, Position2;
7990 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7992 int HLoc1 = GapMapPtr->first.first;
7993 int VLoc1 = GapMapPtr->first.second;
7994 int HLoc2 = GapMapPtr->second.first;
7995 int VLoc2 = GapMapPtr->second.second;
7998 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
8002 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
8006 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
8010 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
8014 unsigned int GapCount = 0;
8016 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
8024 if((
GapMap.size() * 2) != GapCount)
8026 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
8027 (AnsiString)Caller);
8037 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
8041 throw Exception(
"Error - TrackFinished with erase element still present");
8046 AnsiString IDString;
8048 if(TrackElement.
HLoc < 0)
8050 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
8054 IDString = AnsiString(TrackElement.
HLoc) +
"-";
8056 if(TrackElement.
VLoc < 0)
8058 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
8062 IDString += AnsiString(TrackElement.
VLoc);
8077 for(
int x = 1; x < String.Length() + 1; x++)
8079 if(String.IsDelimiter(
"-", x))
8084 if(x == String.Length())
8088 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
8098 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
8103 if(DelimPos == String.Length())
8107 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
8112 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
8116 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
8123 if(String.SubString(1, 1) !=
"N")
8125 for(
int x = 1; x < DelimPos; x++)
8127 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8131 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8138 if(String.SubString(1, 1) ==
"N")
8140 for(
int x = 2; x < DelimPos; x++)
8142 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8146 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8153 if(String.SubString(1, 1) ==
"N")
8155 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
8159 HLoc = String.SubString(1, DelimPos - 1).ToInt();
8161 if(String.SubString(DelimPos + 1, 1) !=
"N")
8163 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
8165 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8169 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8176 if(String.SubString(DelimPos + 1, 1) ==
"N")
8178 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
8180 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8184 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8191 if(String.SubString(DelimPos + 1, 1) ==
"N")
8193 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
8197 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
8202 TrackMapPtr =
TrackMap.find(HVPair);
8207 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
8213 return(TrackMapPtr->second);
8215 catch(
const Exception &e)
8218 ShowMessage(
"Syntax error in track element identifier: <" + String +
">");
8232 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
8233 int HLoc = TrackElement.
HLoc;
8234 int VLoc = TrackElement.
VLoc;
8337 AnsiString(SpeedTag));
8348 if(HVRange.first == HVRange.second)
8355 HVIt1 = HVRange.first;
8360 if(--HVRange.second != HVRange.first)
8362 HVIt2 = HVRange.second;
8366 HVIt2->second).
SpeedTag == SpeedTag)))
8386 AnsiString(SpeedTag));
8452 AnsiString TestString1, TestString2;
8457 throw Exception(
"LNPendingList size not 1 on entry");
8459 int CurrentElementNumber;
8460 bool FoundFlag =
false, ErasedFlag =
false;
8466 int H = CurrentElement->HLoc;
8467 int V = CurrentElement->VLoc;
8468 int Tag = CurrentElement->SpeedTag;
8474 for(
int x = 0; x < 25; x++)
8484 for(
int x = 0; x < 25; x++)
8494 for(
int x = 0; x < 25; x++)
8504 for(
int x = 0; x < 25; x++)
8514 for(
int x = 0; x < 28; x++)
8524 for(
int x = 0; x < 8; x++)
8534 for(
int x = 0; x < 8; x++)
8544 for(
int x = 0; x < 4; x++)
8560 bool FoundFlag2 =
false;
8578 for(
int x = 0; x < 8; x++)
8588 for(
int x = 0; x < 8; x++)
8601 if(CurrentElementNumber > -1)
8606 if((ExistingName !=
"") && (ExistingName != LocationName))
8622 AddName(1, CurrentElement, LocationName);
8626 LNDone2MultiMapEntry.first = HVPair;
8638 if(SNRange.first != SNRange.second)
8642 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8649 TVIt->LocationName =
"";
8650 TVIt->ActiveTrackElementName =
"";
8684 std::pair<AnsiString, char>TempMapPair;
8692 TempMapPair.second =
'x';
8710 AnsiString(SpeedTag));
8720 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8727 int MapPos = -1 - Position;
8731 FoundElement = MapPos;
8747 FoundElement = IMPair.first;
8756 FoundElement = IMPair.second;
8777 AnsiString OldName = TrackElement->LocationName, ErrorString;
8779 TrackElement->LocationName = Name;
8780 int HLoc = TrackElement->HLoc;
8781 int VLoc = TrackElement->VLoc;
8795 if(ErrorString !=
"")
8797 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8821 if(LNDone2MultiMapIterator->second == MapPos)
8848 if(*LNPendingListIterator == MapPos)
8921 if(NameBeingChecked !=
"")
8927 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8935 NameBeingChecked = LNMMRg.second->first;
8937 if(NameBeingChecked !=
"")
8943 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8964 if(LNMMIt->second < 0)
8974 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8982 std::list<THVPair> HVLinkedList;
8985 HVPairsLinkedMap.begin()->second =
true;
8986 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8989 THVPair HVPairUnderExamination;
8990 THVPairsLinkedMap::iterator HVPLMIt;
8992 while(!HVLinkedList.empty())
8994 HVPairUnderExamination = HVLinkedList.front();
8995 HVLinkedList.pop_front();
8996 HVPairNew.first = HVPairUnderExamination.first;
8997 HVPairNew.second = HVPairUnderExamination.second - 1;
8998 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8999 if(HVPLMIt != HVPairsLinkedMap.end())
9001 if(!HVPLMIt->second)
9003 HVLinkedList.push_back(HVPLMIt->first);
9005 HVPLMIt->second =
true;
9007 HVPairNew.first = HVPairUnderExamination.first - 1;
9008 HVPairNew.second = HVPairUnderExamination.second;
9009 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9010 if(HVPLMIt != HVPairsLinkedMap.end())
9012 if(!HVPLMIt->second)
9014 HVLinkedList.push_back(HVPLMIt->first);
9016 HVPLMIt->second =
true;
9018 HVPairNew.first = HVPairUnderExamination.first;
9019 HVPairNew.second = HVPairUnderExamination.second + 1;
9020 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9021 if(HVPLMIt != HVPairsLinkedMap.end())
9023 if(!HVPLMIt->second)
9025 HVLinkedList.push_back(HVPLMIt->first);
9027 HVPLMIt->second =
true;
9029 HVPairNew.first = HVPairUnderExamination.first + 1;
9030 HVPairNew.second = HVPairUnderExamination.second;
9031 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9032 if(HVPLMIt != HVPairsLinkedMap.end())
9034 if(!HVPLMIt->second)
9036 HVLinkedList.push_back(HVPLMIt->first);
9038 HVPLMIt->second =
true;
9043 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
9045 if(!HVPLMIt->second)
9064 if(LocationName ==
"")
9075 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9082 ActiveTrackElementNameMapEntry.second = 0;
9104 bool FoundFlag, ErasedFlag =
false;
9108 if(SNRange.first != SNRange.second)
9111 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9114 TVIt->LocationName =
"";
9115 TVIt->ActiveTrackElementName =
"";
9149 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
9151 AnsiString LocationName;
9160 if(LocationName !=
"")
9168 if(LocationName !=
"")
9182 if(LocationName !=
"")
9184 int ModifiedPosition = -1 - Position;
9193 for(
int x = 0; x < 25; x++)
9203 else if(SpeedTag == 77)
9205 for(
int x = 0; x < 25; x++)
9215 else if(SpeedTag == 78)
9217 for(
int x = 0; x < 25; x++)
9227 else if(SpeedTag == 79)
9229 for(
int x = 0; x < 25; x++)
9239 else if(SpeedTag == 96)
9241 for(
int x = 0; x < 28; x++)
9251 else if(SpeedTag == 129)
9253 for(
int x = 0; x < 8; x++)
9263 else if(SpeedTag == 130)
9265 for(
int x = 0; x < 8; x++)
9275 else if(SpeedTag == 145)
9277 for(
int x = 0; x < 8; x++)
9287 else if(SpeedTag == 146)
9289 for(
int x = 0; x < 8; x++)
9299 else if(SpeedTag == 131)
9301 for(
int x = 0; x < 4; x++)
9321 bool FoundFlag2 =
false;
9348 AnsiString(SpeedTag));
9360 if(TempElement->LocationName !=
"")
9362 LocationName = TempElement->LocationName;
9363 FoundElement = IMPair.first;
9371 if(TempElement->LocationName !=
"")
9373 LocationName = TempElement->LocationName;
9374 FoundElement = IMPair.second;
9386 if(TempElement->LocationName !=
"")
9388 LocationName = TempElement->LocationName;
9389 FoundElement = -1 - Position;
9405 unsigned int Count = 0;
9412 AnsiString SName, TName, ErrorString;
9414 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9420 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9421 AnsiString(Caller));
9434 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9435 AnsiString(Caller));
9442 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9443 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9448 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9454 if(ErrorString !=
"")
9456 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9458 if(SNIt->second != -1 - (
int)x)
9460 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9461 AnsiString(Caller));
9467 bool FoundFlag =
false;
9476 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9477 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9481 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9482 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9483 AnsiString(Caller));
9488 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9489 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9499 if(ErrorString !=
"")
9501 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9503 if(SNIt->second != (
int)x)
9505 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9506 AnsiString(Caller));
9516 AnsiString &ErrorString)
9524 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9526 bool FoundFlag =
false;
9530 if(SNRange.first == SNRange.second)
9532 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9534 return(SNRange.first);
9538 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9540 if(SNIterator->second < 0)
9542 int TVPos = -1 - SNIterator->second;
9544 if(TVIt == TrackElement)
9553 int ITVPos = SNIterator->second;
9555 if(ITVIt == TrackElement)
9566 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9583 LocationNameEntry.first = NewName;
9584 LocationNameEntry.second = SNIterator->second;
9598 int TruePos = -1 - Position;
9602 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9612 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9635 InactiveTrack2MultiMapIterator++)
9637 if(InactiveTrack2MultiMapIterator->second > VecPos)
9639 InactiveTrack2MultiMapIterator->second--;
9647 LocationNameMultiMapIterator++)
9649 if(LocationNameMultiMapIterator->second < 0)
9653 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9655 LocationNameMultiMapIterator->second--;
9677 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9679 if(TrackMapIterator->second > VecPos)
9681 TrackMapIterator->second--;
9689 LocationNameMultiMapIterator++)
9691 if(LocationNameMultiMapIterator->second >= 0)
9697 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9699 LocationNameMultiMapIterator->second++;
9703 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9709 if(TkEl.
Conn[0] ==
int(VecPos))
9714 if(TkEl.
Conn[0] >
int(VecPos))
9718 if(TkEl.
Conn[0] > -1)
9746 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9752 LocationNameEntry.second = -1 - TVPos;
9763 LocationNameEntry.second = ITVPos;
9805 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9837 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9865 AnsiString((
short)FirstTrack));
9866 bool LengthDifferent =
false, SpeedDifferent =
false;
9873 int EXArray[16][2] =
9875 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9876 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9879 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9880 Graphics::TBitmap *Bitmap;
9884 InLink = TrackElement.
Link[0];
9885 OutLink = TrackElement.
Link[1];
9889 InLink = TrackElement.
Link[2];
9890 OutLink = TrackElement.
Link[3];
9892 for(
int x = 0; x < 16; x++)
9894 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9901 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9920 else if(TrackElement.
SpeedTag == 54)
9924 else if(TrackElement.
SpeedTag == 55)
9935 else if(TrackElement.
SpeedTag == 58)
9939 else if(TrackElement.
SpeedTag == 59)
9944 else if(Index == 14)
9950 else if(TrackElement.
SpeedTag == 52)
9954 else if(TrackElement.
SpeedTag == 57)
9959 else if(Index == 15)
9965 else if(TrackElement.
SpeedTag == 53)
9969 else if(TrackElement.
SpeedTag == 56)
9983 if(LengthDifferent && SpeedDifferent)
10051 else if(LengthDifferent && !SpeedDifferent)
10198 AnsiString((
short)FirstTrack));
10199 LengthDifferent =
false;
10200 SpeedDifferent =
false;
10205 LengthDifferent =
true;
10209 SpeedDifferent =
true;
10211 if(LengthDifferent || SpeedDifferent)
10224 LengthDifferent =
true;
10228 SpeedDifferent =
true;
10230 if(LengthDifferent || SpeedDifferent)
10243 LengthDifferent =
true;
10247 SpeedDifferent =
true;
10249 if(LengthDifferent || SpeedDifferent)
10329 AnsiString TempName;
10330 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
10331 bool ForwardSet, ReverseSet;
10333 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10338 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10343 ForwardSet =
false;
10344 ReverseSet =
false;
10378 for(
int y = 0; y < 2; y++)
10409 StartElement = TempElement;
10410 StartVecPos = VecPos;
10413 EntryPos = 1 - Dir;
10414 StartEntryPos = 1 - Dir;
10422 VecPos = TempElement.
Conn[1 - EntryPos];
10423 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10425 EntryPos = TempEntryPos;
10446 ForwardNumber = ((Count + 1) / 2) + 1;
10447 ReverseNumber = (Count - ForwardNumber) + 1;
10449 EntryPos = 1 - Dir;
10450 TempElement = StartElement;
10451 VecPos = StartVecPos;
10452 if(Count == ForwardNumber)
10457 if(Count == ReverseNumber)
10465 VecPos = TempElement.
Conn[1 - EntryPos];
10466 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10468 EntryPos = TempEntryPos;
10470 if(Count == ForwardNumber)
10475 if(Count == ReverseNumber)
10488 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10517 AnsiString TempName;
10518 std::list<unsigned int> NameList;
10519 std::list<AnsiString> ContinuationNameList;
10520 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10526 ContinuationNameList.push_back(
TrackElementAt(1597, x).ActiveTrackElementName);
10529 ContinuationNameList.sort();
10530 ContinuationNameList.unique();
10532 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10537 bool NameIsAContinuation =
false;
10538 if(std::find(ContinuationNameList.begin(), ContinuationNameList.end(), TempElement.
ActiveTrackElementName) != ContinuationNameList.end())
10540 NameIsAContinuation =
true;
10553 if(((TempElement.
Conn[2] > -1)) && (TempElement.
Conn[3] > -1) &&
10561 NameList.push_back(x);
10566 if((TempElement.
Conn[2] > -1) && (TempElement.
Conn[3] > -1) &&
10574 NameList.push_back(x);
10584 NameList.push_back(x);
10587 while(!NameList.empty())
10589 unsigned int a = NameList.front();
10590 NameList.pop_front();
10748 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10804 if((TextH / 16) - 1 <
HLocMin)
10808 if((TextH / 16) + 1 >
HLocMax)
10812 if((TextV / 16) - 1 <
VLocMin)
10816 if((TextV / 16) + 1 >
VLocMax)
10846 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10847 bool &UserGraphicFoundFlag)
10850 TUserGraphicVector::iterator UserGraphicPtr;
10852 UserGraphicFoundFlag =
false;
10859 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10860 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10862 UserGraphicItem = x;
10863 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10864 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10865 UserGraphicFoundFlag =
true;
10883 int SpeedTag = TrackElement.
SpeedTag;
10887 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10936 return(GraphicOutput);
10944 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10947 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10960 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10961 " in InactiveTrackElementAt");
10972 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10974 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10999 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
11000 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
11004 if(SNRange.first == SNRange.second)
11009 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11011 if(SNIterator->second < 0)
11025 HVPair.first = InactiveElement.
HLoc;
11026 HVPair.second = InactiveElement.
VLoc;
11030 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneStationLongEnoughForSplit (1)");
11032 int TVPos =
TrackMap.find(HVPair)->second;
11035 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
11041 FirstNamedExitPos = 0;
11043 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
11045 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
11046 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
11049 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11051 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
11052 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
11053 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
11056 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
11066 FirstNamedExitPos = 1;
11068 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
11070 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
11071 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
11074 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11076 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
11077 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
11078 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
11081 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
11107 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
11108 int FirstNamedExitPos, SecondNamedEntryPos, SecondNamedExitPos;
11112 if(SNRange.first == SNRange.second)
11117 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11119 if(SNIterator->second < 0)
11133 HVPair.first = InactiveElement.
HLoc;
11134 HVPair.second = InactiveElement.
VLoc;
11137 throw Exception (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNonStationLongEnoughForSplit(1)");
11139 int TVPos =
TrackMap.find(HVPair)->second;
11142 if(((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1)) && ((FirstNamedElement.
Conn[2] == -1) || (FirstNamedElement.
Conn[3] == -1)))
11147 if((FirstNamedElement.
Conn[2] == -1) || (FirstNamedElement.
Conn[3] == -1))
11149 FirstNamedExitPos = 0;
11151 SecondNamedElement =
TrackElementAt(1611, FirstNamedElement.
Conn[FirstNamedExitPos]);
11154 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11155 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11157 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11159 else if(SecondNamedEntryPos == 2)
11161 SecondNamedExitPos = 3;
11163 else if(SecondNamedEntryPos == 3)
11165 SecondNamedExitPos = 2;
11167 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11174 FirstNamedExitPos = 1;
11176 SecondNamedElement =
TrackElementAt(1612, FirstNamedElement.
Conn[FirstNamedExitPos]);
11179 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11180 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11182 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11184 else if(SecondNamedEntryPos == 2)
11186 SecondNamedExitPos = 3;
11188 else if(SecondNamedEntryPos == 3)
11190 SecondNamedExitPos = 2;
11192 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11200 else if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
11202 FirstNamedExitPos = 2;
11204 SecondNamedElement =
TrackElementAt(1613, FirstNamedElement.
Conn[FirstNamedExitPos]);
11207 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11208 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11210 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11212 else if(SecondNamedEntryPos == 2)
11214 SecondNamedExitPos = 3;
11216 else if(SecondNamedEntryPos == 3)
11218 SecondNamedExitPos = 2;
11220 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11227 FirstNamedExitPos = 3;
11229 SecondNamedElement =
TrackElementAt(1614, FirstNamedElement.
Conn[FirstNamedExitPos]);
11232 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11233 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11235 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11237 else if(SecondNamedEntryPos == 2)
11239 SecondNamedExitPos = 3;
11241 else if(SecondNamedEntryPos == 3)
11243 SecondNamedExitPos = 2;
11245 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11262 int MidEntryPos,
int &FrontTrainFrontPos,
int &FrontTrainRearPos,
int &RearTrainFrontPos,
int &RearTrainRearPos,
bool &TemporaryDelay)
11270 LocationName + AnsiString(LeadElement) +
"," + AnsiString(LeadExitPos) +
"," + AnsiString(MidElement) +
"," + AnsiString(MidEntryPos));
11272 TemporaryDelay =
false;
11274 int FwdPos[3] = {LeadElement, -1, -1};
11275 int RwdPos[3] = {MidElement, -1, -1};
11278 int FwdPos1EntryPos, FwdPos1ExitPos, FwdPos2EntryPos, FwdPos2ExitPos, RwdPos1EntryPos, RwdPos1ExitPos, RwdPos2EntryPos, RwdPos2ExitPos;
11280 bool FwdDerail1 =
false, FwdDerail2 =
false, RwdDerail1 =
false, RwdDerail2 =
false;
11281 int NumFwdNamedElements = 0, NumFwdElements = 0, NumRwdNamedElements = 0, NumRwdElements = 1;
11284 NumRwdNamedElements = 1;
11287 FwdPos[1] = FwdPos0Element.
Conn[LeadExitPos];
11290 NumFwdElements = 1;
11294 NumFwdNamedElements = 1;
11296 FwdPos1EntryPos = FwdPos0Element.
ConnLinkPos[LeadExitPos];
11298 FwdPos[2] = FwdPos1Element.
Conn[FwdPos1ExitPos];
11301 NumFwdElements = 2;
11302 FwdPos2EntryPos = FwdPos1Element.
ConnLinkPos[FwdPos1ExitPos];
11307 NumFwdNamedElements = 2;
11313 RwdPos[1] = RwdPos0Element.
Conn[MidEntryPos];
11316 NumRwdElements = 2;
11320 NumRwdNamedElements = 2;
11322 RwdPos1ExitPos = RwdPos0Element.
ConnLinkPos[MidEntryPos];
11324 RwdPos[2] = RwdPos1Element.
Conn[RwdPos1EntryPos];
11327 NumRwdElements = 3;
11328 RwdPos2ExitPos = RwdPos1Element.
ConnLinkPos[RwdPos1EntryPos];
11333 NumRwdNamedElements = 3;
11340 if(NumFwdNamedElements == 2)
11342 FrontTrainFrontPos = FwdPos[2];
11343 FrontTrainRearPos = FwdPos[1];
11344 RearTrainFrontPos = LeadElement;
11345 RearTrainRearPos = MidElement;
11346 if(FwdDerail1 || FwdDerail2)
11348 TrainController->
StopTTClockMessage(159, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11349 TemporaryDelay =
true;
11355 TrainController->
StopTTClockMessage(160, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11356 TemporaryDelay =
true;
11362 TrainController->
StopTTClockMessage(161, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11363 TemporaryDelay =
true;
11371 else if((NumFwdNamedElements == 1) && (NumRwdNamedElements >= 1) && (NumRwdElements >= 2))
11373 FrontTrainFrontPos = FwdPos[1];
11374 FrontTrainRearPos = LeadElement;
11375 RearTrainFrontPos = MidElement;
11376 RearTrainRearPos = RwdPos[1];
11379 TrainController->
StopTTClockMessage(162, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11380 TemporaryDelay =
true;
11386 TrainController->
StopTTClockMessage(163, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11387 TemporaryDelay =
true;
11393 TrainController->
StopTTClockMessage(164, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11394 TemporaryDelay =
true;
11400 TrainController->
StopTTClockMessage(165, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11401 TemporaryDelay =
true;
11409 else if((NumRwdNamedElements >= 2) && (NumRwdElements == 3))
11411 FrontTrainFrontPos = LeadElement;
11412 FrontTrainRearPos = MidElement;
11413 RearTrainFrontPos = RwdPos[1];
11414 RearTrainRearPos = RwdPos[2];
11415 if(RwdDerail1 || RwdDerail2)
11417 TrainController->
StopTTClockMessage(166, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11418 TemporaryDelay =
true;
11424 TrainController->
StopTTClockMessage(167, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11425 TemporaryDelay =
true;
11431 TrainController->
StopTTClockMessage(168, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11432 TemporaryDelay =
true;
11441 else if((NumFwdNamedElements == 1) && (NumFwdElements == 2))
11443 FrontTrainFrontPos = FwdPos[2];
11444 FrontTrainRearPos = FwdPos[1];
11445 RearTrainFrontPos = LeadElement;
11446 RearTrainRearPos = MidElement;
11447 if(FwdDerail1 || FwdDerail2)
11449 TrainController->
StopTTClockMessage(169, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11450 TemporaryDelay =
true;
11456 TrainController->
StopTTClockMessage(170, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11457 TemporaryDelay =
true;
11463 TrainController->
StopTTClockMessage(171, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11464 TemporaryDelay =
true;
11472 else if((NumFwdElements >= 1) && (NumRwdNamedElements >= 1) && (NumRwdElements >= 2))
11474 FrontTrainFrontPos = FwdPos[1];
11475 FrontTrainRearPos = LeadElement;
11476 RearTrainFrontPos = MidElement;
11477 RearTrainRearPos = RwdPos[1];
11480 TrainController->
StopTTClockMessage(172, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11481 TemporaryDelay =
true;
11487 TrainController->
StopTTClockMessage(173, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11488 TemporaryDelay =
true;
11494 TrainController->
StopTTClockMessage(174, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11495 TemporaryDelay =
true;
11501 TrainController->
StopTTClockMessage(175, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11502 TemporaryDelay =
true;
11522 if(SNRange.first != SNRange.second)
11524 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11526 if(SNIterator->second < 0)
11548 "," + AnsiString(SpeedTag));
11559 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
11589 else if(SpeedTag == 69)
11615 else if(SpeedTag == 70)
11641 else if(SpeedTag == 71)
11678 AnsiString(LinkPos) +
"," + AnsiString(OwnTrainID));
11679 if((LinkPos < 0) || (TrackPos < 0))
11711 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
11723 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
11724 bool FoundFlag =
false;
11739 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
11740 bool FoundFlag =
false;
11765 VPosHi = 16 * VLocHi;
11766 VPosLo = 16 * VLocLo;
11785 AnsiString(EndTVPosition));
11796 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
11797 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
11798 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
11799 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
11801 if(Link0Squares <= Link1Squares)
11819 AnsiString(LinkPos));
11838 if((LinkPos == 1) && (TE.
Attribute == 0))
11843 else if(LinkPos == 1)
11849 else if((LinkPos == 3) && (TE.
Attribute == 1))
11854 else if(LinkPos == 3)
11861 else if(LinkPos == 0)
11866 else if(LinkPos == 1)
11871 else if(LinkPos == 2)
11876 else if(LinkPos == 3)
11881 throw Exception(
"Error, failure in GetExitPos");
11930 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11934 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11976 "," + AnsiString(DiagonalLinkNumber));
11981 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11986 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11991 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11996 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
12012 AnsiString JustFileName =
"";
12017 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
12024 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
12043 typedef std::list<int> TNamePosList;
12044 TNamePosList NamePosList;
12045 typedef TNamePosList::iterator TNPLIt;
12047 typedef std::list<int> TOnePlatList;
12048 TOnePlatList OnePlatList;
12049 typedef TOnePlatList::iterator TOPLIt;
12052 NamePosList.clear();
12053 OnePlatList.clear();
12054 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
12056 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
12058 NamePosList.push_back(x);
12063 if(!NamePosList.empty())
12065 OnePlatList.push_back(NamePosList.back());
12066 NamePosList.pop_back();
12068 while(!OnePlatList.empty())
12070 TempInt = OnePlatList.front();
12073 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
12074 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
12076 OnePlatList.push_back(TempElement.
Conn[0]);
12077 NamePosList.erase(NPLIt);
12079 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
12080 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
12082 OnePlatList.push_back(TempElement.
Conn[1]);
12083 NamePosList.erase(NPLIt);
12086 OnePlatList.erase(OnePlatList.begin());
12087 if(OnePlatList.empty())
12090 if(!NamePosList.empty())
12092 OnePlatList.push_back(NamePosList.back());
12093 NamePosList.pop_back();
12109 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not signal in RepairFailedSignals");
12113 throw Exception(
"Signals not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedSignals");
12141 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not points in RepairFailedPoints");
12145 throw Exception(
"Points not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedPoints");
12171 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not simple in RepairFailedPoints");
12175 throw Exception(
"No TSR at " + AnsiString(FPVIt->TVPos) +
" in RepairTSR");
12197 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
12216 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
12231 throw Exception(
"Return value negative in call to LastElementNumber");
12243 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
12257 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
12269 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
12270 " in GetModifiablePrefDirElementAt");
12280 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
12282 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
12292 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
12294 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
12311 int TrackVectorPosition;
12362 FinishElement =
false;
12363 int TrackVectorPosition;
12385 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
12395 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
12418 for(
int x = 0; x < 4; x++)
12441 FinishElement =
true;
12449 for(
int x = 0; x < 4; x++)
12461 FinishElement =
true;
12469 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12476 .ELinkPos] ==
Lead))
12492 FinishElement =
true;
12511 FinishElement =
true;
12530 FinishElement =
true;
12545 FinishElement =
true;
12554 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12570 FinishElement =
true;
12576 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12599 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
12600 int VectorCount = 0;
12604 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
12606 for(
int x = 0; x < VectorCount; x++)
12613 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
12617 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
12618 SearchElement.
ELinkPos = NextELinkPos;
12639 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
12641 SearchElement.
XLinkPos = NextXLinkPos;
12667 for(
int x = 0; x < VectorCount; x++)
12679 for(
int x = 0; x < VectorCount; x++)
12693 for(
int x = 0; x < VectorCount; x++)
12707 for(
int x = 0; x < VectorCount; x++)
12717 for(
int x = 0; x < VectorCount; x++)
12728 SearchElement.
XLink = SearchElement.
Link[1];
12747 SearchElement.
XLink = SearchElement.
Link[3];
12760 for(
int x = 0; x < VectorCount; x++)
12775 XLinkPos = NextXLinkPos;
12776 CurrentTrackElement = SearchElement;
12795 throw Exception(
"Error, SearchVector empty");
12802 for(
int x = 0; x < 4; x++)
12855 throw Exception(
"Error in EntryExitNumber 1");
12874 if(PrefDirElement.
XLink == -1)
12886 if(PrefDirElement.
XLink != -1)
12890 throw Exception(
"Error in EntryExitNumber 2");
12928 LeadingPoints =
false;
12956 LeadingPoints =
true;
12972 AnsiString ErrorString;
12973 bool Error =
false;
12980 ErrorString =
"HLoc";
12986 ErrorString =
"VLoc";
12992 ErrorString =
"ELink";
12998 ErrorString =
"ELinkPos";
13004 ErrorString =
"XLink";
13010 ErrorString =
"XLinkPos";
13016 ErrorString =
"Tag";
13022 ErrorString =
"TrackVectorPosition";
13028 ErrorString =
"EXNumber";
13035 ErrorString =
"CheckCount";
13042 ErrorString =
"EntryGraphicPtr";
13048 ErrorString =
"EntryDirectionGraphicPtr";
13057 ErrorString =
"Last XLink not connected to this element";
13064 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
13088 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
13145 AnsiString((
short)BuildingPrefDir));
13148 if(PrefDirSize() == 0)
13153 for(
unsigned int x = 0; x < PrefDirSize(); x++)
13165 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
13177 if(x == (PrefDirSize() - 1))
13186 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
13188 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
13189 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
13190 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
13192 if(PrefDirSize() > 1)
13194 unsigned int LatestPos = PrefDirSize() - 1;
13195 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
13196 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
13197 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
13218 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13221 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13225 H = MMIT->first.first;
13226 V = MMIT->first.second;
13229 if(PrefDirPos0 > -1)
13233 if(PrefDirPos1 > -1)
13237 if(PrefDirPos2 > -1)
13241 if(PrefDirPos3 > -1)
13245 if(PrefDirPos3 > -1)
13261 else if(PrefDirPos2 > -1)
13303 else if(PrefDirPos1 > -1)
13326 else if(PrefDirPos0 > -1)
13345 int NumberOfPrefDirElements = 0;
13348 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13350 VecFile >> TempInt;
13353 VecFile >> TempInt;
13354 LoadPrefDirElement.
ELink = TempInt;
13355 VecFile >> TempInt;
13356 LoadPrefDirElement.
ELinkPos = TempInt;
13357 VecFile >> TempInt;
13358 LoadPrefDirElement.
XLink = TempInt;
13359 VecFile >> TempInt;
13360 LoadPrefDirElement.
XLinkPos = TempInt;
13361 VecFile >> TempInt;
13362 LoadPrefDirElement.
EXNumber = TempInt;
13363 VecFile >> TempInt;
13368 if(!(LoadPrefDirElement.
IsARoute))
13394 int NumberOfPrefDirElements = 0;
13397 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13399 VecFile >> TempInt;
13400 VecFile >> TempInt;
13403 VecFile >> TempInt;
13404 LoadPrefDirElement.
ELink = TempInt;
13405 VecFile >> TempInt;
13406 LoadPrefDirElement.
ELinkPos = TempInt;
13407 VecFile >> TempInt;
13408 LoadPrefDirElement.
XLink = TempInt;
13409 VecFile >> TempInt;
13410 LoadPrefDirElement.
XLinkPos = TempInt;
13411 VecFile >> TempInt;
13412 LoadPrefDirElement.
EXNumber = TempInt;
13413 VecFile >> TempInt;
13418 if(!(LoadPrefDirElement.
IsARoute))
13446 int NumberOfPrefDirElements = 0;
13449 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
13454 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13461 VecFile >> TempInt;
13462 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
13467 VecFile >> TempInt;
13468 if((TempInt < -1) || (TempInt > 9))
13473 VecFile >> TempInt;
13474 if((TempInt < -1) || (TempInt > 3))
13479 VecFile >> TempInt;
13480 if((TempInt < -1) || (TempInt > 9))
13485 VecFile >> TempInt;
13486 if((TempInt < -1) || (TempInt > 3))
13491 VecFile >> TempInt;
13492 if((TempInt < -1) || (TempInt > 27))
13497 VecFile >> TempInt;
13505 VecFile >> TempInt;
13506 if((TempInt != 0) && (TempInt != 1))
13511 VecFile >> TempInt;
13512 if((TempInt != 0) && (TempInt != 1))
13517 VecFile >> TempInt;
13518 if((TempInt != 0) && (TempInt != 1))
13541 for(
int y = 0; y < NumberOfPrefDirElements; y++)
13543 VecFile << y <<
'\n';
13544 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
13554 if(y == (NumberOfPrefDirElements - 1))
13556 VecFile <<
"************" <<
'\0' <<
'\n';
13560 VecFile <<
"******" <<
'\0' <<
'\n';
13574 for(
int y = 0; y < NumberOfSearchElements; y++)
13576 VecFile << y <<
'\n';
13577 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
13587 if(y == (NumberOfSearchElements - 1))
13589 VecFile <<
"************" <<
'\0' <<
'\n';
13593 VecFile <<
"******" <<
'\0' <<
'\n';
13706 bool AlreadyPresent, FoundFlag;
13707 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13709 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
13713 AlreadyPresent =
false;
13718 AlreadyPresent =
true;
13722 AlreadyPresent =
true;
13726 AlreadyPresent =
true;
13730 AlreadyPresent =
true;
13733 if(!AlreadyPresent)
13780 for(
unsigned int z = 0; z < 4; z++)
13788 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
13802 bool DiscrepancyFound =
false;
13813 DiscrepancyFound =
true;
13818 DiscrepancyFound =
true;
13823 DiscrepancyFound =
true;
13828 DiscrepancyFound =
true;
13833 DiscrepancyFound =
true;
13839 DiscrepancyFound =
true;
13842 if(DiscrepancyFound)
13844 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
13859 bool DiscrepancyFound =
false;
13870 DiscrepancyFound =
true;
13874 DiscrepancyFound =
true;
13879 DiscrepancyFound =
true;
13884 DiscrepancyFound =
true;
13889 DiscrepancyFound =
true;
13895 DiscrepancyFound =
true;
13899 return(!DiscrepancyFound);
13911 bool FoundFlag =
false;
13912 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
13920 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
13921 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
13923 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
13925 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
13926 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
13927 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
13932 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
13933 +
" Caller=" + (AnsiString)Caller);
13959 PrefDirMapKeyPair.first = HLoc;
13960 PrefDirMapKeyPair.second = VLoc;
13961 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13964 if(ItPair.first == ItPair.second)
13972 PrefDirPos0 = ItPair.first->second;
13974 if(ItPair.first == ItPair.second)
13979 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13981 PrefDirPos1 = ItPair.first->second;
13984 if(ItPair.first == ItPair.second)
13989 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13991 PrefDirPos2 = ItPair.first->second;
13994 if(ItPair.first == ItPair.second)
13999 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
14001 PrefDirPos3 = ItPair.first->second;
14016 +
"," + AnsiString(LinkNumberPos));
14018 int PD0, PD1, PD2, PD3;
14019 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
14023 PD0, PD1, PD2, PD3);
14035 LinkedPrefDirVectorNumber = PD0;
14044 LinkedPrefDirVectorNumber = PD1;
14054 LinkedPrefDirVectorNumber = PD0;
14063 LinkedPrefDirVectorNumber = PD1;
14072 LinkedPrefDirVectorNumber = PD2;
14081 LinkedPrefDirVectorNumber = PD3;
14086 LinkedPrefDirVectorNumber = -1;
14092 LinkedPrefDirVectorNumber = -1;
14097 catch(
const Exception &e)
14099 LinkedPrefDirVectorNumber = -1;
14114 +
"," + AnsiString(LinkNumberPos));
14116 int PD0, PD1, PD2, PD3;
14117 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
14121 PD0, PD1, PD2, PD3);
14134 LinkedPrefDirVectorNumber = PD0;
14144 LinkedPrefDirVectorNumber = PD1;
14149 LinkedPrefDirVectorNumber = -1;
14157 LinkedPrefDirVectorNumber = PD0;
14166 LinkedPrefDirVectorNumber = PD1;
14175 LinkedPrefDirVectorNumber = PD2;
14184 LinkedPrefDirVectorNumber = PD3;
14189 LinkedPrefDirVectorNumber = -1;
14195 LinkedPrefDirVectorNumber = -1;
14200 catch(
const Exception &e)
14202 LinkedPrefDirVectorNumber = -1;
14214 int PD0, PD1, PD2, PD3;
14266 THVPair PrefDir4MultiMapKeyPair;
14269 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
14270 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
14271 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
14294 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
14313 AnsiString(ErasedElementNumber));
14318 if(MapPtr->second > ErasedElementNumber)
14340 throw Exception(
"PrefDirVectorPosition out of range");
14343 THVPair PrefDir4MultiMapKeyPair;
14345 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
14346 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
14347 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14350 if(ItPair.first == ItPair.second)
14353 return(ItPair.first);
14357 if(ItPair.first->second == PrefDirVectorPosition)
14361 return(ItPair.first);
14364 if(ItPair.first == ItPair.second)
14367 return(ItPair.first);
14369 if(ItPair.first->second == PrefDirVectorPosition)
14373 return(ItPair.first);
14376 if(ItPair.first == ItPair.second)
14379 return(ItPair.first);
14381 if(ItPair.first->second == PrefDirVectorPosition)
14385 return(ItPair.first);
14388 if(ItPair.first == ItPair.second)
14391 return(ItPair.first);
14393 if(ItPair.first->second == PrefDirVectorPosition)
14397 return(ItPair.first);
14401 return(ItPair.first);
14414 THVPair PrefDir4MultiMapKeyPair;
14416 PrefDir4MultiMapKeyPair.first = HLoc;
14417 PrefDir4MultiMapKeyPair.second = VLoc;
14418 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14421 if(ItPair.first == ItPair.second)
14429 return(ItPair.first->second);
14438 bool ErasedFlag =
false;
14440 if(ErasedTrackVectorPosition > -1)
14449 ErasedFlag =
false;
14451 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
14456 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
14461 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
14466 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
14471 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
14479 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
14483 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
14487 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
14491 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
14495 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
14510 OverallDistance = 0;
14511 OverallSpeedLimit = 0;
14512 LeadingPointsAtLastElement =
false;
14520 LeadingPointsAtLastElement =
true;
14529 OverallDistance += PrefDirElement.
Length23;
14530 if(OverallSpeedLimit != -1)
14540 OverallSpeedLimit = -1;
14547 OverallDistance += PrefDirElement.
Length01;
14548 if(OverallSpeedLimit != -1)
14558 OverallSpeedLimit = -1;
14577 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14580 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14584 HLoc = MMIT->first.first;
14585 VLoc = MMIT->first.second;
14590 if(PrefDirPos0 > -1)
14594 if(PrefDirPos1 > -1)
14598 if(PrefDirPos2 > -1)
14602 if(PrefDirPos3 > -1)
14606 if(PrefDirPos3 > -1)
14609 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14611 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14613 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14615 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
14622 else if(PrefDirPos2 > -1)
14627 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14629 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14631 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
14640 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14642 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14644 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14653 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14655 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14657 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14664 else if(PrefDirPos1 > -1)
14669 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14671 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14679 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14681 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14687 else if(PrefDirPos0 > -1)
14689 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14706 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14709 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14731 if(PrefDirPos0 > -1)
14735 if(PrefDirPos1 > -1)
14739 if(PrefDirPos2 > -1)
14743 if(PrefDirPos3 > -1)
14747 if(PrefDirPos3 > -1)
14752 else if(PrefDirPos2 > -1)
14754 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
14765 else if(PrefDirPos1 > -1)
14767 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
14778 else if(PrefDirPos0 > -1)
14780 if(PrefDirElement0.
XLinkPos == EntryPos)
14817 ElementIn.
VLoc +
"," + XLink);
14819 bool TrackFoundFlag;
14822 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
14834 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14844 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14858 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14868 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14882 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14892 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14906 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14916 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14939 bool FoundFlag, ContFlag, FoundElements =
false;
14940 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14945 LastIteratorValue++;
14971 if(PDVIt->XLinkPos == 0)
14976 StartElement = *PDVIt;
14985 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
14987 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14988 if(PrefDirPos0 == -1)
14992 bool NextElementFoundFlag =
false;
14996 NextElementFoundFlag =
true;
14998 if(PrefDirPos1 > -1)
15003 NextElementFoundFlag =
true;
15006 if(PrefDirPos2 > -1)
15011 NextElementFoundFlag =
true;
15014 if(PrefDirPos3 > -1)
15019 NextElementFoundFlag =
true;
15022 if(!NextElementFoundFlag)
15052 EndElement = NextElement;
15056 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
15058 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15059 if(PrefDirPos0 == -1)
15069 if(PrefDirPos1 > -1)
15077 if(PrefDirPos2 > -1)
15085 if(PrefDirPos3 > -1)
15116 FoundElements =
true;
15150 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
15152 int TrackVectorPosition;
15188 int LockedVectorNumber;
15211 bool InPrefDirFlag =
false;
15214 int PrefDirPos0 = -1;
15215 int PrefDirPos1 = -1;
15216 int PrefDirPos2 = -1;
15217 int PrefDirPos3 = -1;
15221 int PrefDirVecPos[4] =
15223 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15226 for(
int x = 0; x < 4; x++)
15228 int b = PrefDirVecPos[x];
15238 InPrefDirFlag =
true;
15251 TrainController->
StopTTClockMessage(12,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
15259 if(DummyPair.first > -1)
15261 throw Exception(
"Selection in two routes - should never happen!");
15263 if(RoutePair.first > -1)
15339 IDInt &ReqPosRouteID,
bool &PointsChanged)
15373 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
15375 int NewFailedPointsTVPos = -1;
15424 bool InPrefDirFlag =
false;
15427 int PrefDirPos0 = -1;
15428 int PrefDirPos1 = -1;
15429 int PrefDirPos2 = -1;
15430 int PrefDirPos3 = -1;
15433 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15434 int PrefDirVecPos[4] =
15436 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15439 for(
int x = 0; x < 4; x++)
15441 int b = PrefDirVecPos[x];
15444 InPrefDirFlag =
true;
15457 TrainController->
StopTTClockMessage(23,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
15466 if(RoutePair.first > -1)
15468 if(RoutePair.second != 0)
15485 EndElement1 = RouteElement;
15486 EndElement2 = BlankElement;
15581 AutoSigsFlag,
false))
15586 if(NewFailedPointsTVPos > -1)
15590 " failed during route setting.");
15594 PointsChanged =
true;
15617 AutoSigsFlag,
false))
15622 if(NewFailedPointsTVPos > -1)
15626 " failed during route setting.");
15630 PointsChanged =
true;
15648 AutoSigsFlag,
false))
15653 if(NewFailedPointsTVPos > -1)
15657 " failed during route setting.");
15661 PointsChanged =
true;
15685 AutoSigsFlag,
false))
15690 if(NewFailedPointsTVPos > -1)
15694 " failed during route setting.");
15698 PointsChanged =
true;
15707 AutoSigsFlag,
false))
15712 if(NewFailedPointsTVPos > -1)
15716 " failed during route setting.");
15720 PointsChanged =
true;
15731 AutoSigsFlag,
false))
15736 if(NewFailedPointsTVPos > -1)
15740 " failed during route setting.");
15744 PointsChanged =
true;
15750 AutoSigsFlag,
false))
15755 if(NewFailedPointsTVPos > -1)
15759 " failed during route setting.");
15763 PointsChanged =
true;
15774 AutoSigsFlag,
false))
15779 if(NewFailedPointsTVPos > -1)
15783 " failed during route setting.");
15787 PointsChanged =
true;
15841 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag,
bool RecursiveCall)
15893 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
15894 AnsiString((
short)AutoSigsFlag) +
"," + AnsiString((
short)RecursiveCall));
15895 int VectorCount = 0;
15904 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
15908 for(
int x = 0; x < VectorCount; x++)
15916 bool FirstPass =
true;
15926 for(
int x = 0; x < VectorCount; x++)
15935 for(
int x = 0; x < VectorCount; x++)
15947 for(
int x = 0; x < VectorCount; x++)
15955 int NextPosition = PrefDirElement.
Conn[XLinkPos];
15959 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
15960 SearchElement.
ELinkPos = NextELinkPos;
15961 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
15982 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
15984 SearchElement.
XLinkPos = NextXLinkPos;
16002 for(
int x = 0; x < VectorCount; x++)
16018 for(
int x = 0; x < VectorCount; x++)
16032 if(RoutePair.first > -1)
16041 for(
int x = 0; x < VectorCount; x++)
16050 if(SecondPair.first > -1)
16059 for(
int x = 0; x < VectorCount; x++)
16073 for(
int x = 0; x < VectorCount; x++)
16084 for(
int x = 0; x < VectorCount; x++)
16093 for(
int x = 0; x < VectorCount; x++)
16102 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16106 for(
int x = 0; x < VectorCount; x++)
16116 bool InPrefDirFlag =
false;
16117 PrefDirElement1 = BlankElement;
16118 PrefDirElement2 = BlankElement;
16121 int PrefDirPos0 = -1;
16122 int PrefDirPos1 = -1;
16123 int PrefDirPos2 = -1;
16124 int PrefDirPos3 = -1;
16127 int PrefDirVecPos[4] =
16129 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
16131 for(
int x = 0; x < 4; x++)
16133 int b = PrefDirVecPos[x];
16136 InPrefDirFlag =
true;
16149 for(
int x = 0; x < VectorCount; x++)
16161 for(
int x = 0; x < VectorCount; x++)
16177 for(
int x = 0; x < VectorCount; x++)
16188 for(
int x = 0; x < VectorCount; x++)
16208 for(
int x = 0; x < VectorCount; x++)
16221 for(
int x = 0; x < VectorCount; x++)
16235 for(
int x = 0; x < VectorCount; x++)
16245 for(
int x = 0; x < VectorCount; x++)
16276 for(
int x = 0; x < VectorCount; x++)
16285 for(
int x = 0; x < VectorCount; x++)
16297 int SearchPos1 = SearchElement.
Attribute + 1;
16299 if(SearchPos1 == 2)
16303 if(SearchPos1 == 1)
16311 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
16312 SearchElement.
XLinkPos = SearchPos1;
16313 InPrefDirFlag =
false;
16314 if(SearchElement.
XLink == PrefDirElement1.
XLink)
16316 SearchElement = PrefDirElement1;
16317 InPrefDirFlag =
true;
16319 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
16321 SearchElement = PrefDirElement2;
16322 InPrefDirFlag =
true;
16328 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16332 for(
int x = 0; x < VectorCount; x++)
16350 AutoSigsFlag,
true))
16359 for(
int x = 0; x < VectorCount; x++)
16368 for(
int x = 0; x < VectorCount; x++)
16388 for(
int x = 0; x < VectorCount; x++)
16398 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
16399 SearchElement.
XLinkPos = SearchPos2;
16400 if(SearchElement.
XLink == PrefDirElement1.
XLink)
16402 SearchElement = PrefDirElement1;
16404 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
16406 SearchElement = PrefDirElement2;
16410 for(
int x = 0; x < VectorCount; x++)
16418 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16422 for(
int x = 0; x < VectorCount; x++)
16441 AutoSigsFlag,
true))
16450 for(
int x = 0; x < VectorCount; x++)
16459 for(
int x = 0; x < VectorCount; x++)
16471 for(
int x = 0; x < VectorCount; x++)
16481 SearchElement = PrefDirElement1;
16490 XLinkPos = SearchElement.
XLinkPos;
16491 PrefDirElement = SearchElement;
16548 unsigned int TruncatePrefDirPosition = 0;
16621 throw Exception(
"Error - failed to validate extended route for preferred route");
16676 throw Exception(
"Error - failed to validate single route for preferred route");
16721 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
16723 int TrackVectorPosition;
16760 int LockedVectorNumber;
16794 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
16795 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
16798 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
16804 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
16805 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
16808 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
16822 if(RoutePair.first > -1)
16957 int NewFailedPointsTVPos = -1;
17022 EndElement1.
ELink = EndElement1.
Link[0];
17023 EndElement1.
XLink = EndElement1.
Link[1];
17026 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
17031 EndElement2.
ELink = EndElement2.
Link[1];
17032 EndElement2.
XLink = EndElement2.
Link[0];
17035 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
17079 if(RoutePair.first > -1)
17081 if(RoutePair.second != 0)
17104 EndElement2 = BlankElement;
17189 if(NewFailedPointsTVPos > -1)
17193 " failed during route setting.");
17197 PointsChanged =
true;
17223 if(NewFailedPointsTVPos > -1)
17227 " failed during route setting.");
17231 PointsChanged =
true;
17253 if(NewFailedPointsTVPos > -1)
17257 " failed during route setting.");
17261 PointsChanged =
true;
17287 if(NewFailedPointsTVPos > -1)
17291 " failed during route setting.");
17295 PointsChanged =
true;
17309 if(NewFailedPointsTVPos > -1)
17313 " failed during route setting.");
17317 PointsChanged =
true;
17357 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
17358 int VectorCount = 0;
17361 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
17362 (CurrentTrackElement.
Link[XLinkPos] == 9))
17366 for(
int x = 0; x < VectorCount; x++)
17378 for(
int x = 0; x < VectorCount; x++)
17385 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
17387 for(
int x = 0; x < VectorCount; x++)
17394 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
17398 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
17399 SearchElement.
ELinkPos = NextELinkPos;
17420 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
17422 SearchElement.
XLinkPos = NextXLinkPos;
17440 for(
int x = 0; x < VectorCount; x++)
17456 for(
int x = 0; x < VectorCount; x++)
17470 if(RoutePair.first > -1)
17479 for(
int x = 0; x < VectorCount; x++)
17488 if(SecondPair.first > -1)
17497 for(
int x = 0; x < VectorCount; x++)
17511 for(
int x = 0; x < VectorCount; x++)
17522 for(
int x = 0; x < VectorCount; x++)
17531 for(
int x = 0; x < VectorCount; x++)
17540 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17544 for(
int x = 0; x < VectorCount; x++)
17557 for(
int x = 0; x < VectorCount; x++)
17585 for(
int x = 0; x < VectorCount; x++)
17598 for(
int x = 0; x < VectorCount; x++)
17608 for(
int x = 0; x < VectorCount; x++)
17633 for(
int x = 0; x < VectorCount; x++)
17642 for(
int x = 0; x < VectorCount; x++)
17655 int SearchPos1 = SearchElement.
Attribute + 1;
17657 if(SearchPos1 == 2)
17661 if(SearchPos1 == 1)
17670 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
17671 SearchElement.
XLinkPos = SearchPos1;
17673 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17677 for(
int x = 0; x < VectorCount; x++)
17695 for(
int x = 0; x < VectorCount; x++)
17711 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
17712 SearchElement.
XLinkPos = SearchPos2;
17714 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17718 for(
int x = 0; x < VectorCount; x++)
17734 for(
int x = 0; x < VectorCount; x++)
17746 for(
int x = 0; x < VectorCount; x++)
17761 CurrentTrackElement = SearchElement;
17762 XLinkPos = SearchElement.
XLinkPos;
17784 throw Exception(
"Error, SearchVector empty");
17796 for(
int x = 0; x < 4; x++)
17838 throw Exception(
"Error in EntryExitNumber 3");
17893 unsigned int TruncatePrefDirPosition = 0;
17953 throw Exception(
"Failed to validate extended route for nonpreferred route");
17998 throw Exception(
"Failed to validate single route for nonpreferred route");
18018 if(!PrefDirVector.empty())
18022 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
18027 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
18044 if(!PrefDirVector.empty())
18049 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
18066 NewFailedPointsTVPos = -1;
18067 bool PointsChanged =
false;
18075 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
18085 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
18086 IFE.
TVPos = NewFailedPointsTVPos;
18105 PointsChanged =
true;
18108 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
18118 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
18119 IFE.
TVPos = NewFailedPointsTVPos;
18138 PointsChanged =
true;
18144 return(PointsChanged);
18168 NextForwardLinkedRouteNumber = -1;
18169 for(
unsigned int x = StartPos; x < PrefDirSize(); x++)
18171 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
18172 if(PrefDirVector.at(x).TrackType ==
Bridge)
18174 if(PrefDirVector.at(x).XLinkPos < 2)
18176 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit01;
18180 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit23;
18188 if(PrefDirVector.at(x).TrackType ==
Buffers)
18200 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
18209 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
18211 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute;
18223 if(x == PrefDirSize() - 1)
18226 NextForwardLinkedRouteNumber = -1;
18274 AnsiString(PrefDirVectorStartPosition));
18280 if(!PrefDirVector.empty())
18282 if(!SkipForwardLook)
18284 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
18287 if(PrefDirPtr->TrackType ==
Bridge)
18289 if(PrefDirPtr->XLinkPos < 2)
18300 SkipForwardLook =
true;
18308 SkipForwardLook =
true;
18311 int NextForwardLinkedRouteNumber = -1;
18312 if((
unsigned int)PrefDirVectorStartPosition == PrefDirSize() - 1)
18314 TPrefDirElement PDE = GetFixedPrefDirElementAt(267, PrefDirVectorStartPosition);
18319 SkipForwardLook =
true;
18320 if(PrefDirVector.back().TrackType ==
Buffers)
18326 bool SetAttributeTo3 =
true;
18337 SetAttributeTo3 =
false;
18338 Attribute = AutoSigVectorIT->AccessNumber;
18344 if(SetAttributeTo3)
18355 SkipForwardLook =
true;
18356 if(PrefDirVector.back().TrackType ==
Buffers)
18369 if(!SkipForwardLook)
18374 if((
unsigned int)PrefDirVectorStartPosition < (PrefDirSize() - 1))
18376 StartPos = PrefDirVectorStartPosition + 1;
18384 if(!FindForwardTargetSignalAttribute(2, NextForwardLinkedRouteNumber, Attribute, StartPos))
18403 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
18406 if(PrefDirPtr->TrackType ==
Bridge)
18408 if(PrefDirPtr->XLinkPos < 2)
18424 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
18433 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
18436 PrefDirPtr->PrefDirRoute)
18440 int LockedVecNum = 0;
18442 bool KeepAttributeAt0ForLockedRoute =
false;
18447 KeepAttributeAt0ForLockedRoute =
true;
18452 bool NotGroundSignal =
false;
18455 NotGroundSignal =
true;
18480 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute && (NotGroundSignal || (Attribute == 0)))
18509 "," + AnsiString((
short)PrefDirRoute));
18510 bool ElementInRoute =
false;
18511 bool MovingTrainOccupyingRoute =
false;
18512 unsigned int TruncatePDElementPos;
18513 enum {NoTruncate, BackTruncate, FrontTruncate, FullTruncate} TruncateType;
18514 TruncateType = NoTruncate;
18521 TruncatePDElementPos = b;
18522 ElementInRoute =
true;
18526 if(!ElementInRoute)
18536 if(TruncatePDElementPos == 0)
18538 TruncateType = FullTruncate;
18546 TruncateType = FrontTruncate;
18550 TruncateType = BackTruncate;
18557 TruncateType = BackTruncate;
18563 if(TruncateType == BackTruncate)
18583 MovingTrainOccupyingRoute =
true;
18594 if(b ==
int(TruncatePDElementPos))
18600 else if(TruncateType == FrontTruncate)
18620 MovingTrainOccupyingRoute =
true;
18631 if(b == TruncatePDElementPos)
18657 MovingTrainOccupyingRoute =
true;
18679 if(((TruncatePDElementPos == 1) && (TruncateType == BackTruncate)) || ((TruncatePDElementPos == (
PrefDirSize() - 2)) && (TruncateType == FrontTruncate)))
18688 if((TruncatePDElementPos > 0) && (TruncateType == BackTruncate))
18695 TrainController->
StopTTClockMessage(145,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18696 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18697 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18717 else if((TruncatePDElementPos < (
PrefDirSize() - 1)) && (TruncateType == FrontTruncate))
18724 TrainController->
StopTTClockMessage(146,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18725 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18726 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18735 if(TruncatePDElementPos > 0)
18750 else if(TruncatePDElementPos == 0)
18757 TrainController->
StopTTClockMessage(148,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18758 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18759 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18779 int ThisRouteNumber;
18789 if(LRVIT->RouteNumber == ThisRouteNumber)
18800 unsigned int LookBackwardsFromHere = 0;
18801 if(TruncateType == BackTruncate)
18803 LookBackwardsFromHere = TruncatePDElementPos;
18815 int button = Application->MessageBox(L
"Moving train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
18816 L
"Warning!", MB_YESNO | MB_ICONWARNING);
18829 bool ExistingLockedRouteModified =
false;
18831 if(TruncateType == BackTruncate)
18837 else if(TruncateType == FrontTruncate)
18858 if(LRVIT->RouteNumber == ThisRouteNumber)
18862 ExistingLockedRouteModified =
true;
18866 if(!ExistingLockedRouteModified)
18870 if(TruncateType == BackTruncate)
18873 RearPosition = TruncatePDElementPos;
18876 else if(TruncateType == FrontTruncate)
18880 FrontPosition = TruncatePDElementPos;
18889 for(
int c = FrontPosition; c >= RearPosition; c--)
18907 if(TruncateType == BackTruncate)
18909 RearPosition = TruncatePDElementPos;
18913 else if(TruncateType == FrontTruncate)
18916 FrontPosition = TruncatePDElementPos;
18933 for(
int c = FrontPosition; c >= RearPosition; c--)
18977 TPrefDirElement NewGreenFirstPDElement, NewRedFirstPDElement, NewGreenLastPDElement, NewRedLastPDElement;
18990 if(RouteColour == 1)
18992 NewRedFirstPDElement = LastPDElement;
18996 NewRedFirstPDElement.
IsARoute =
true;
19002 if(R2MMIt->second.first ==
int(x))
19004 R2MMIt->second.second++;
19011 else if(RouteColour == 2)
19013 NewGreenFirstPDElement = LastPDElement;
19017 NewGreenFirstPDElement.
IsARoute =
true;
19023 if(R2MMIt->second.first ==
int(x))
19025 R2MMIt->second.second++;
19048 if(RouteColour == 1)
19050 NewRedLastPDElement = FirstPDElement;
19059 else if(RouteColour == 2)
19061 NewGreenLastPDElement = FirstPDElement;
19130 ARVIt->SetRouteSignals(14);
19149 AnsiString((
short)PrefDirRoute));
19174 AnsiString((
short)PrefDirRoute));
19184 RouteFlashElement.
HLoc = H;
19185 RouteFlashElement.
VLoc = V;
19201 int H = PrefDirPtr->HLoc;
19202 int V = PrefDirPtr->VLoc;
19269 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
19275 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
19278 OverlayPlotted =
false;
19301 bool FirstSignalFound =
false;
19308 if(PDVIt->TrackType ==
Points)
19310 if((PDVIt->ELinkPos == 1) || (PDVIt->XLinkPos == 1))
19321 else if((PDVIt->ELinkPos == 3) || (PDVIt->XLinkPos == 3))
19336 int XLinkPosition = PDVIt->XLinkPos;
19337 if(PDVIt->XLinkPos == -1)
19341 for(
int x = 0; x < 4; x++)
19343 if(PDVIt->Conn[x] == (PDVIt + 1)->TrackVectorPosition)
19356 if(XLinkPosition > -1)
19358 if(!FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
19360 FirstSignalFound =
true;
19363 else if(FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
19374 IFE.
TVPos = PDVIt->TrackVectorPosition;
19380 " failed when changing aspect.\nTrains can only pass under signaller control.");
19410 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
19412 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
19415 return(AllRoutesVector.at(At));
19423 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
19425 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
19428 return(AllRoutesVector.at(At));
19439 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19441 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
19451 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19453 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
19471 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
19472 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19476 GetModifiableRouteAt(7, a).TruncateRoute(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
19505 AnsiString(LinkPos));
19506 if(TrackVectorPosition == -1)
19511 THVPair Route2MultiMapKeyPair;
19515 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19518 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19528 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19530 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19533 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
19534 Route2MultiMapIterator->second.second);
19535 EntryLinkPos = PrefDirElement1.
ELinkPos;
19536 ExitLinkPos = PrefDirElement1.
XLinkPos;
19537 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19538 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19550 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19562 Graphics::TBitmap* &EntryDirectionGraphicPtr)
19572 AnsiString(LinkPos));
19575 if(TrackVectorPosition == -1)
19580 THVPair Route2MultiMapKeyPair;
19584 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19587 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19592 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19594 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19596 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
19597 Route2MultiMapIterator->second.second);
19598 EntryLinkPos = PrefDirElement1.
ELinkPos;
19599 ExitLinkPos = PrefDirElement1.
XLinkPos;
19600 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19601 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19605 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
19606 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19613 return(AutoSigsRoute);
19618 return(NotAutoSigsRoute);
19624 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
19625 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19632 return(AutoSigsRoute);
19637 return(NotAutoSigsRoute);
19641 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19643 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19644 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19646 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
19647 EntryLinkPos = PrefDirElement2.
ELinkPos;
19648 ExitLinkPos = PrefDirElement2.
XLinkPos;
19649 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19650 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19654 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
19661 return(AutoSigsRoute);
19666 return(NotAutoSigsRoute);
19672 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
19679 return(AutoSigsRoute);
19684 return(NotAutoSigsRoute);
19688 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
19689 EntryLinkPos = PrefDirElement3.
ELinkPos;
19690 ExitLinkPos = PrefDirElement3.
XLinkPos;
19691 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19692 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19696 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
19703 return(AutoSigsRoute);
19708 return(NotAutoSigsRoute);
19714 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
19721 return(AutoSigsRoute);
19726 return(NotAutoSigsRoute);
19742 AnsiString(LinkPos));
19743 if(TrackVectorPosition == -1)
19749 THVPair Route2MultiMapKeyPair;
19753 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19756 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19762 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19764 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19766 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
19767 Route2MultiMapIterator->second.second);
19768 EntryLinkPos = PrefDirElement1.
ELinkPos;
19769 ExitLinkPos = PrefDirElement1.
XLinkPos;
19770 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19771 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19774 RouteNumber = Route2MultiMapIterator->second.first;
19778 return(AutoSigsRoute);
19783 return(NotAutoSigsRoute);
19788 RouteNumber = Route2MultiMapIterator->second.first;
19792 return(AutoSigsRoute);
19797 return(NotAutoSigsRoute);
19801 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19803 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19804 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19806 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
19807 EntryLinkPos = PrefDirElement2.
ELinkPos;
19808 ExitLinkPos = PrefDirElement2.
XLinkPos;
19809 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19810 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19813 RouteNumber = ItPair.first->second.first;
19817 return(AutoSigsRoute);
19822 return(NotAutoSigsRoute);
19827 RouteNumber = ItPair.first->second.first;
19831 return(AutoSigsRoute);
19836 return(NotAutoSigsRoute);
19840 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
19841 EntryLinkPos = PrefDirElement3.
ELinkPos;
19842 ExitLinkPos = PrefDirElement3.
XLinkPos;
19843 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19844 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19847 RouteNumber = ItPair.second->second.first;
19851 return(AutoSigsRoute);
19856 return(NotAutoSigsRoute);
19861 RouteNumber = ItPair.second->second.first;
19865 return(AutoSigsRoute);
19870 return(NotAutoSigsRoute);
19892 EmptyRoute.
RouteID = NextRouteID;
19895 AllRoutesVector.push_back(EmptyRoute);
19896 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19921 AllRoutesVector.push_back(EmptyRoute);
19922 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19945 THVPair Route2MultiMapKeyPair;
19954 LockedRouteRearTrackVectorPosition = 0;
19955 LockedRouteLastTrackVectorPosition = 0;
19956 LockedRouteLastXLinkPos = 0;
19957 LockedRouteLockStartTime = TDateTime(0);
19958 if(!LockedRouteVector.empty())
19962 if(LRVIT->RouteNumber == RouteNumber)
19964 LockedRouteRearTrackVectorPosition = LRVIT->RearTrackVectorPosition;
19965 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
19966 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
19967 LockedRouteLockStartTime = LRVIT->LockStartTime;
19968 LockedRouteFoundDuringRouteBuilding =
true;
19969 LockedRouteVector.erase(LRVIT);
19994 AnsiString(VLoc) +
"," + AnsiString(ELink));
19997 ReturnPair.first = -1;
19998 ReturnPair.second = 0;
19999 THVPair Route2MultiMapKeyPair;
20001 Route2MultiMapKeyPair.first = HLoc;
20002 Route2MultiMapKeyPair.second = VLoc;
20005 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
20006 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20008 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20009 Route2MultiMapIterator = ItPair.first;
20011 if(ItPair.first == ItPair.second)
20013 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
20015 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
20017 ReturnPair.first = ItPair.first->second.first;
20018 ReturnPair.second = ItPair.first->second.second;
20019 Route2MultiMapIterator = ItPair.first;
20021 return(ReturnPair);
20024 if(ItPair.first == ItPair.second)
20026 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
20028 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
20030 ReturnPair.first = ItPair.first->second.first;
20031 ReturnPair.second = ItPair.first->second.second;
20032 Route2MultiMapIterator = ItPair.first;
20034 return(ReturnPair);
20037 return(ReturnPair);
20052 AnsiString(VLoc) +
"," + AnsiString(ELink));
20053 THVPair Route2MultiMapKeyPair;
20055 Route2MultiMapKeyPair.first = HLoc;
20056 Route2MultiMapKeyPair.second = VLoc;
20057 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20059 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20061 if(ItPair.first == ItPair.second)
20067 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
20069 RouteNumber = ItPair.first->second.first;
20075 if(ItPair.first == ItPair.second)
20081 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
20083 RouteNumber = ItPair.first->second.first;
20104 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
20105 THVPair Route2MultiMapKeyPair;
20107 Route2MultiMapKeyPair.first = HLoc;
20108 Route2MultiMapKeyPair.second = VLoc;
20111 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
20114 RouteElementPair.first = RouteNumber;
20115 RouteElementPair.second = RouteElementNumber;
20116 Route2MultiMapEntry.second = RouteElementPair;
20118 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
20121 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
20122 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
20125 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
20126 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
20128 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
20130 Route2MultiMap.insert(Route2MultiMapEntry);
20135 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
20140 Route2MultiMap.insert(Route2MultiMapEntry);
20158 TempPair.first = -1;
20159 TempPair.second = 0;
20160 SecondPair = TempPair;
20162 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
20163 THVPair Route2MultiMapKeyPair;
20165 Route2MultiMapKeyPair.first = HLoc;
20166 Route2MultiMapKeyPair.second = VLoc;
20167 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
20172 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
20174 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
20176 return(Route2MultiMapIterator->second);
20178 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
20180 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20181 TempPair = ItRange.first->second;
20182 SecondPair = (--ItRange.second)->second;
20205 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
20206 if(RouteElementPair.first == -1)
20209 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
20210 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
20212 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
20215 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
20216 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
20217 (AnsiString)Caller);
20219 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
20222 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
20223 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
20224 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
20225 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
20229 unsigned int SizeVal = 0;
20232 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
20234 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
20236 if(SizeVal != Route2MultiMap.size())
20238 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
20239 (AnsiString)Caller);
20255 if(!Route2MultiMap.empty())
20257 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
20259 if(Route2MultiMapIterator->second.first > RouteNumber)
20261 Route2MultiMapIterator->second.first--;
20278 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
20279 if(!Route2MultiMap.empty())
20281 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
20283 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
20285 Route2MultiMapIterator->second.second--;
20304 AnsiString(ELink));
20308 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
20309 if(RequiredRoutePair.first == -1)
20311 throw Exception(
"Failed to find route element in RemoveRouteElement");
20313 Route2MultiMap.erase(Route2MultiMapIterator);
20314 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
20317 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
20338 GetModifiableRouteAt(8, RequiredRoutePair.first).PrefDirVector.erase(GetModifiableRouteAt(33, RequiredRoutePair.first).PrefDirVector.begin() + RequiredRoutePair.second);
20349 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
20357 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
20359 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
20360 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
20361 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
20373 if(!LockedRouteVector.empty())
20377 if(LRVIT->RouteNumber > RequiredRoutePair.first)
20379 LRVIT->RouteNumber--;
20389 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
20391 AutoSigVectorIT->RouteNumber--;
20396 CheckMapAndRoutes(7);
20410 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
20411 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
20412 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
20429 "," + AnsiString(XLinkPos));
20433 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
20434 if(RouteElementPair.first == -1)
20436 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
20438 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
20440 RequiredPair = RouteElementPair;
20441 if(RouteElement.
XLinkPos != XLinkPos)
20443 if(SecondPair.first != -1)
20445 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
20446 RequiredPair = SecondPair;
20447 if(RouteElement.
XLinkPos != XLinkPos)
20449 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
20454 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
20458 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
20479 AnsiString(AccessNumber));
20481 int Attribute = AccessNumber;
20483 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
20487 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
20491 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
20494 x).XLinkPos] !=
End)
20496 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
20499 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
20550 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
20551 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
20552 int RearwardLinkedRouteNumber;
20555 bool SkipForwardLook =
false;
20564 SkipForwardLook =
true;
20566 RearwardLinkedRouteNumber).
PrefDirSize() - 1, SkipForwardLook)))
20576 int TrainID, TrainPosition, BehindTrainPosition;
20577 bool FoundTrain =
false, BehindTrain =
false;
20578 for(
int x = RouteStartPosition; x >= 0; x--)
20580 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
20605 if(FoundTrain && (TrainPosition > 1))
20609 for(
int x = TrainPosition; x >= 0; x--)
20613 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
20633 BehindTrain =
true;
20634 BehindTrainPosition = x;
20641 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
20658 AnsiString(LookBackwardsFromHere));
20659 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber;
20660 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
20663 bool ExamineRoute =
true;
20665 while(ExamineRoute)
20667 for(
int x = LookBackwardsFromHere; x >= 0; x--)
20712 if(SignalCount >= 3)
20727 LookBackwardsFromHere = CurrentRoute.
PrefDirSize() - 1;
20731 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
20732 ExamineRoute =
true;
20733 LookBackwardsFromHere = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
20768 ExamineRoute =
false;
20783 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
20786 PrefDirElement = InternalPrefDirElement;
20787 if(LockedRouteVector.empty())
20794 bool InLockedRoute =
false;
20798 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
20802 InLockedRoute =
true;
20811 int RouteNumber, VectorCount = 0;
20816 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
20817 if(RouteType == NoRoute)
20830 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
20832 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
20837 PrefDirElement = InternalPrefDirElement;
20838 LockedVectorNumber = VectorCount;
20843 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->RearTrackVectorPosition)
20847 PrefDirElement = InternalPrefDirElement;
20848 LockedVectorNumber = VectorCount;
20869 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20871 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
20877 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
20887 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20889 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
20904 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20906 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
20909 return(GetFixedRouteAt(159, x));
20912 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20920 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20922 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
20925 return(GetModifiableRouteAt(15, x));
20928 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20938 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20940 TOneRoute OneRoute = GetFixedRouteAt(165, x);
20952 int NumberOfRoutes;
20956 for(
int x = 0; x < NumberOfRoutes; x++)
20963 StoreOneRouteAfterSessionLoad(0, &OneRoute);
20981 if((NumberOfRoutes < 0) || (NumberOfRoutes > 10000))
20988 if((NextID < 0) || (NextID > 1000000))
20993 for(
int x = 0; x < NumberOfRoutes; x++)
21018 AnsiString(StartPosition));
21019 if(EndPosition == StartPosition)
21025 int TVPos = EndPosition;
21026 int LkPos = EndXLinkPos;
21028 while(TrackIsInARoute(15, TVPos, LkPos))
21055 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
21064 if((NewLkPos == 0) || (NewLkPos == 2))
21084 if(TVPos == StartPosition)
21116 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
21121 if(FirstPair.first > -1)
21124 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21129 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21135 if(SecondPair.first > -1)
21138 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21143 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21149 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
21156 if(FirstPair.first > -1)
21159 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21164 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21170 if(SecondPair.first > -1)
21173 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21178 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21184 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
21191 if(FirstPair.first > -1)
21194 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21199 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21205 if(SecondPair.first > -1)
21208 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21213 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21219 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
21226 if(FirstPair.first > -1)
21229 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21234 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21240 if(SecondPair.first > -1)
21243 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21248 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21254 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
21278 "," + AnsiString(DiagonalLinkNumber));
21283 if(FirstPair.first > -1)
21286 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21291 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21297 if(SecondPair.first > -1)
21300 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21305 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21312 if(FirstPair.first > -1)
21315 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21320 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21326 if(SecondPair.first > -1)
21329 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21334 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
21341 if(FirstPair.first > -1)
21344 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21349 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21355 if(SecondPair.first > -1)
21358 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21363 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
21370 if(FirstPair.first > -1)
21373 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21378 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
21384 if(SecondPair.first > -1)
21387 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
21392 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))